Page 1 of 1

Related Records

Posted: Wed Nov 20, 2002 1:41 pm
by AliasBDI
I have a DETAILS.PHP page which has two quieries: (1) for the table called 'articles' and (2) for the 'related_articles'. I need the 'related_articles' to query the database for records that have the 'title' of the query before.

This is what happens...

From the INDEX.PHP, the user sees a list of articles (titles of the articles). The user clicks on the particular article they wish to view and the page goes to DETAILS.PHP and displays the selected record's details. Also, on this page I want a list of "Related Links". The 'related_articles' basically takes the 'title' field of the displayed record and queries the 'articles' table with it.

What is the string for the 'related_articles' query?

Posted: Thu Nov 21, 2002 2:07 am
by twigletmac
It's difficult to write an SQL statement when you have no idea how the database table's are set up. But assuming that you have the 'title' field of the record you are showing stored in a variable (e.g. $title):

Code: Select all

SELECT field1, field2, field3 FROM articles WHERE somefield = '$title'
Is this the kind of thing you are looking for?

Mac