PDA

Click to See Complete Forum and Search --> : [RESOLVED] Mysql_num_rows & while(*************) {


..:RUDI:..
Apr 11th, 2006, 10:31 AM
ok so here's my code:
<?
$threadquery = "SELECT * FROM threads WHERE fid = $forumid";
$threadresult = mysql_query($threadquery);
while ($row = mysql_fetch_assoc($threadresult)) {
$tid = $row['topicid'];
$postquery = mysql_query("SELECT * FROM posts WHERE tid = '".$row['topicid']."';");
}
$countposts = mysql_num_rows($postquery);
echo $countposts ;
?>
from that, I only get 1 result from the num_rows. However, there are two threads, each with a reply, therefore, the post count should be 2.

What I think is happening:
I think that, because while ($row = mysql_fetch_assoc($threadresult)) {
$tid = $row['topicid']; produces an array of numbers for ech thread, maybe the mysql_num_rows() is only getting one of the array members, possibly I could use for each???

Any help is greatly appreciated.
Regards,
Rudi
:cool:

..:RUDI:..
Apr 12th, 2006, 02:49 AM
Fixed using a different method.
:)

john tindell
Apr 12th, 2006, 03:11 AM
If its fixed can you mark your thread as resolved, Thanks

..:RUDI:..
Apr 12th, 2006, 06:26 AM
I had already clicked it :eek: