Msg#: 3763884 posted 12:13 am on Oct 12, 2008 (gmt 0)
Hello, I am a major PHP newbie. I have an existing site (in Perl). I am trying to create a new page in PHP that will basically query the database and then display those results in a table. I've done fine so far however I am now stuck. Basically, I would like to know how to query 2 separate tables. I have my script setup to grab info from the first table called "articles" but I also need to get some info from a second table called "comments". There is a common denominator between the two tables, however the column name is not the same. In articles I have a column named "entry" and in "comments" it is referred to as "entryid". Inside the "comments" field, there is a "counter" with how many comments each article has. I would like to be able to only show results when the comments table has a NULL in the column of "counter".
So query the info from two tables BUT only show the result if the column in the second table does not have a value (its NULL meaning no comments have been made). Can anyone help me with this or point me in the right direction. This is what I have so far (which only pulls all the data within the first table):
//connect to mysql mysql_connect(localhost,$username,$password);
Msg#: 3763884 posted 5:02 am on Oct 12, 2008 (gmt 0)
Hey phranque, I will try that out and post the results. And yes, I agree about the counter. I'm not the original programmer of my site but I definitely thought the same thing when I looked at the database. Thank you for taking the time to help. I am off to see if that works :)