|
Posted by dseeker on 05/23/07 04:00
hi, I have a confusing problem here - The while loop inside the first
while loop only go through the whole loop once, regardless how many
rows actually inside $tagresult!!
Here are the code :
mysql_connect($hostname,$username,$pwd) or die("Failure to connect to
the database");
mysql_select_db($dbid);
$query = "select * from blog order by date DESC LIMIT 3";
$result = mysql_query($query);
while( $row = mysql_fetch_row($result) ) {
echo "<tr><td>Date: $row[2]</td></tr>\n";
echo "<tr><td>Topics Mentioned: ";
$tagquery = "select * from blog_tag1 where blogID=".
$row[0];
$tagresult = mysql_query($tagquery);
$num_rows = mysql_num_rows($tagresult);
echo "the number of row got returned is:
$num_rows"; // Even it shows more than 1 row, the following while loop
only print one $tag[1]!!
while( $tagrow = mysql_fetch_row($tagresult) ) {
$tagquery = "select * from blog_tagname where
tagID=".$tagrow[2];
$tagresult = mysql_query($tagquery);
$tag = mysql_fetch_row($tagresult);
echo $tag[1];
}
...
}
Hope I can see some replies soon, as I am very confused right now!!!
Thanks for you time!!
Navigation:
[Reply to this message]
|