Outputting Various Entries from a Databse

Hello everyone

On my site there is a page which contains data taken from the latest entry in the database.

I also want to have links to the other entries but am unsure as to how to replace the original data with the ‘older’ data that the user has clicked.

I have thought I could link to different PHP pages with that data on but surely there’s a more efficient way of doing it?

Uuh, could you more clearly describe what you want, what goes wrong and post some source code with that, and any errors you’re getting? I for one am getting pretty confused on that you just wrote :confused:

my apologies

my code works at the moment , which is to output the latest entry of the database on to a page

on the same page i want links to other entries in the database.

when clicked they will replace the original information

sort of like this site http://musicthing.blogspot.com/ where you have the main article on the left, links on the right…then by clicking one of the links on the right a new page is generated

you could pass the value of the page as a GET variable and upload the content for the main article of the page based on the passed value and on the “Navigation” you could do a query to get all the articles you want to make available.

for example http://phphelp.com/article/article.php?art=1 where art is the variable passed. Based on it’s value, that article makes it into the main section of the site. No although I don’t have a list of the remaining articles, it’s a simple enough query to add a frame (or div or span, etc…) to put the remaining articles.

without wanting to sound too thick, how would I go about doing this?

You could try something like this (in pseudo-code):

Database structure for table 'articles':
- articleID
- articleTitle
- articleMessage
- isPublic

On the navigation:
SELECT articleID, articleTitle FROM articles WHERE isPublic = 1 ORDER BY articleID
while (fetchArray()) {

On the main page:
$articleID = intval($_GET['article']);
SELECT * FROM articles WHERE articleID = $articleID

I’ll leave it up to you to transform this to valid PHP code (or Java/C/C++/C#/ASP/VB/Python/etc. basically everything works, except for this).

Sponsor our Newsletter | Privacy Policy | Terms of Service