Related Records

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Related Records

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply