Skip to content
Advertisement

Display each sql db row in a single php page

I’m trying to display each single row from my db as a separated unique page, so when I click on the row link (which I don’t even know what it is until now) it directs me to a new page with the content of this row or some of the content as I desire..

So I created a new php file, and inserted this code but it doesn’t work after all.

Tried to include ?id= into the url to see if I can actually access a row in a unique page, but still doesn’t work.

I am a beginner, so I hope the answer will be simple enough for me to understand.

I want to know what should I do to generate a page for each row I have?

Edit:

PROBLEM SOLVED BY CHANGING THE CODE INTO THIS (BUT i have another issue):

But sadly i have another problem..

I wanna display a URL for each row in my database on my main page, but i dont wanna do this manually one by one, i want it to be generated dynamically through a loop.

What im using on my main page:

I want to loop the process.

EDIT(SOLVED):

Updated Code:

Advertisement

Answer

You can fetch all the rows on the page and then display it as links using the fetch_assoc function

you can also use SELECT * FROM jokes_tableif you want other columns from the database table.

this will get all the rows of the table and display it as a link that will go to their respective page.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement