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 = ""; } Quote 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. Quote 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++) { Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.