Database Link in PHP

Instructions from the assignment:

  1. Create a link called “users”
  • When clicking on “users” it shows the username and password for all users as they are stored in the database
  • Note, in the real world, this is foolish and an obvious security risk. However, for grading purposes (and since this is not a real site), I need it to be present

I can make a link from my localhost phpMyAdmin, but it does not work with my remote phpMyAdmin. I am using Host Gator as my hosting for this class and I contacted them and they said that you can’t use a link to connect to the database. Any other ideas on how to share the database with my teacher. He says he wants a link, and I have emailed him for instruction or help but haven’t heard from him. :frowning: I am not sure how else to do this so that he can view the information.

Well, I would switch classes. Any teacher who starts out explaining a “link” as to a user table and who tells you to do something wrong should not be a teacher! ( In my humble opinion ! )

When he says a link, he means you need to create a webpage. The link will point at that page. The page would need to attach itself to the database and display all of the users in the user table. This normally would never be done without a secured login and password. Therefore, he is tell you to do something WRONG! He should lean how to teach students by using a product table, not a user’s table.

So, create a webpage that connects to his database and lists the info in it. You would NEVER do this. First, you never share passwords as they should be encrypted. This is so wrong!

Yeah I have been learning this over this semester but the semester only has one month left so I am stuck.

So this teacher also wants everything within one php file instead of multiples. I don’t know SQL very well and he hasn’t taught us how to accomplish this ask. If I want to view the whole database I need to make the query (SELECT * FROM user;, correct?), but then how do I echo that information out by clicking a “link”?

Well, you must have a connection system set up. One that the teacher gave you.
That is needed. A link points to a webpage. So, you create a webpage on your server and the address of the webpage is a URL which is a link. Like https://www.google.com/ That is a link to google…

And, in that page, you have a connection set up to your database.
Then, next you create the SELECT * from user if the name of the user’s table is called “user”
Then, you loop thru the results using FETCH() function to read each line of data and print the user names and passwords.

That’s about all I can help you with. If you are almost done with the semester, you should already have created pages of code. That is created early on in your class.

Yes, I have a webpage that I am creating for the class all on one file and I have a database. The part he hasn’t taught us is how to echo out a database with the fetch function and I am guessing I need to do this with a button. I will look around online and see if I can find the info I need.

Well, here is a good place to start at. It has every language on the top and sub-areas of learning on the right once you select a language. On this linked page, you will see examples of getting data from a database and displaying it. That site does not always have the best examples programming wise, but, it does give you a great place to start with and learn on your own. Start with that and when you get stuck post a new question here and we can help you. Good luck… Select and Display data

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service