Comments

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
nachoman316
Forum Newbie
Posts: 12
Joined: Sat Apr 11, 2009 6:40 am

Comments

Post by nachoman316 »

Hello I am trying to link user comments to particular articles in a website I am developing.

I have two mysql database tables Programme and Comments.

Programme has a primary key of progid which is also a foreign key in Comments.

But I am having trouble with the query retrieving the programme article and the comments attached to that article in the same page.

Im a total noob Im more of a front end developer but would love to get more experience with php.

Any help would be great.

Thanks Nacho.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Comments

Post by Apollo »

Code: Select all

SELECT * FROM Programme WHERE progid=37; // this will select a specific programme
 
SELECT * FROM Comments WHERE progid=37; // this selects the comments that belong to it
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Comments

Post by papa »

Or one query:

Code: Select all

 
SELECT * FROM Programme AS a
JOIN Comments AS b ON a.progid=b.progid
WHERE a.progid = 37
 
nachoman316
Forum Newbie
Posts: 12
Joined: Sat Apr 11, 2009 6:40 am

Re: Comments

Post by nachoman316 »

Thanks for the help guys I'll give those a bash.

Cheers Nacho
Post Reply