How can I do this?? :((

From: Date: Tue, 06 Feb 2001 00:46:17 +0000
Subject: How can I do this?? :((
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38340@lists.php.net to get a copy of this message
Hi all, I'm basically really struggling with this query, so would appreciate any pointers on how I could do this. I've included my experimental code underneath, and need to make it work. The first query, which I know works, pulls info from a mysql table. Now for each of my diary entry, I want people to be able to add comments. All comments go into another table which records what section that comment came from (which is diary), and the id (which it takes from the id number of the diary entry). Now what I want to do is have another query which asks the second table the number of comments per each section id, for that section, (and I think QUERY2 does this fine). But I need the answers to integrate with the information pulled from first query. How can I intergrate the results from 2 queries into one basically! CODE *************************** $query1 = " SELECT entry FROM diary WHERE month='$month' ORDER BY id desc"; $result1 = mysql_query($query1); $query2 = "SELECT count(*) AS replies FROM sexsurvey_boys WHERE section='diary' GROUP BY sectionid ORDER BY sectionid desc"; $result2 = mysql_query($query2); if ($result1) { echo "<table border=0 cellspacing=0 cellpadding=2 width=90% align=center>"; while ($r = mysql_fetch_array($result)) { extract($r); $entry = nl2br($entry); echo " <tr bgcolor=#ffffff><td colspan=2>$entry<br></td></tr> <tr bgcolor=#ffffff> <td>&raquo; <a href=\"javascript:popupwin('popupwindow.php?section=diary&sectionid=$id',200,530)\">comment on this diary entry</a></td> <td align=right>read comments, (0) so far.</td></tr> "; } } else { echo "Whoops!"; } mysql_free_result($result1); ********************* TIA! Sunny __________________________________________________ Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/

« previous php.general (#38340) next »