You are here: A Strange mysql_fetch_row() problem...Help me to find the bug in my code!!! « PHP Programming Language « IT news, forums, messages
A Strange mysql_fetch_row() problem...Help me to find the bug in my code!!!

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация