ghurty Posted July 1, 2009 Share Posted July 1, 2009 I have a HTML file calling a php script. The Php scipt pulls from the sql table a list. The html file using the following code puts the list in a list format. Is there a way that I can have it that every other item on the list will cycle between two DIV's instead of one? Thanks <div class="List1"> <ul> %%List%% </ul> </div> And %%List%% is generated by: <li>%%Name%%</li> Which gets its list from a sql query Link to comment https://forums.phpfreaks.com/topic/164421-can-i-have-it-that-each-row-from-php-query-will-be-in-different-div/ Share on other sites More sharing options...
mattal999 Posted July 1, 2009 Share Posted July 1, 2009 Well, the PHP to pull from the db would look like this: <?php $count = 0; $query = mysql_query("SELECT..."); while($item = mysql_fetch_array($query)) { if($count == 0) { $count = 1; echo "<div class=\"divtype1\">Div Class 1</div>"; } else { $count = 0; echo "<div class=\"divtype2\">Div Class 2</div>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/164421-can-i-have-it-that-each-row-from-php-query-will-be-in-different-div/#findComment-867305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.