Jump to content

Can I have it that each row from php query will be in different DIV?


ghurty

Recommended Posts

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

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>";
}
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.