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 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++; }; 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 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
Archived
This topic is now archived and is closed to further replies.