c_pattle Posted October 7, 2010 Share Posted October 7, 2010 I have this code but when I run it I get this error "Parse error: syntax error, unexpected T_WHILE" Can I not have a while loop in a while loop? while ( $article_array = mysql_fetch_array ( $article_rs ) ) {$tags = explode(", ", $article_array['article_tags']);$article_tags = "<ul class=\"tags\">"while ($i=0; $i<count($tags);$i++) { $article_tags .= "<li><a href=\"index.php?tag=" . $tags[$i] . "\">" . $tags[$i] . "</a></li>";}$article_tags .= "</ul>"; echo ("just getting stuff from database here");$article_tags = ""; } Link to comment https://forums.phpfreaks.com/topic/215378-a-while-loop-in-a-while-loop/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2010 Share Posted October 7, 2010 You can as long as your php syntax is correct. You are missing a semi-colon ; on the end of the line of code right before the second while() statement. Link to comment https://forums.phpfreaks.com/topic/215378-a-while-loop-in-a-while-loop/#findComment-1120005 Share on other sites More sharing options...
c_pattle Posted October 7, 2010 Author Share Posted October 7, 2010 thanks for such a quick reply. I changed that but now I am getting this error "Parse error: syntax error, unexpected ';'". This corresponds to the following code. while ($i=0; $i<count($tags);$i++) { Link to comment https://forums.phpfreaks.com/topic/215378-a-while-loop-in-a-while-loop/#findComment-1120007 Share on other sites More sharing options...
roopurt18 Posted October 7, 2010 Share Posted October 7, 2010 while ($i=0; $i<count($tags);$i++) { That should be a for loop. Link to comment https://forums.phpfreaks.com/topic/215378-a-while-loop-in-a-while-loop/#findComment-1120009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.