avillanu Posted August 16, 2007 Share Posted August 16, 2007 I'm trying to create a table using a MySQL fetch array while loop that would look like this: CONTENT1 CONTENT2 CONTENT3 CONTENT4 CONTENT5 CONTENT6 I need a <TR></TR> for every other piece of content. But I don't know how to do this with a loop that uses a MySQL fetch array while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { PHP CODE THAT IS LOOPED;}; I'm trying to remember from my old college Java class that we did something with loops for whenever the counter variable was even the loop would do something special...I don't know if this is possible with a while+mysql_fetch_array loop though Quote Link to comment https://forums.phpfreaks.com/topic/65298-solved-creating-table-rows-for-ever-other-loop-in-a-while-loop/ Share on other sites More sharing options...
lemmin Posted August 16, 2007 Share Posted August 16, 2007 You can just make your own counter: $i=0 while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { If ($i%2==0) //column 1 else //column 2 $i++; }; Quote Link to comment https://forums.phpfreaks.com/topic/65298-solved-creating-table-rows-for-ever-other-loop-in-a-while-loop/#findComment-326100 Share on other sites More sharing options...
avillanu Posted August 22, 2007 Author Share Posted August 22, 2007 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/65298-solved-creating-table-rows-for-ever-other-loop-in-a-while-loop/#findComment-331325 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.