For loop
Posted: Mon Oct 04, 2010 11:43 pm
Hi guys,
I've got a three-column CSS-designed layout and in each of those columns I'm trying to put a value from my database. However, I'm very new to this and cant quite figure out the logic for doing it. Below is my code.
Can anyone please tell me how I can get the three IDs in each of the columns and if there are more than three IDs how I do it on a new row etc.
I've got a three-column CSS-designed layout and in each of those columns I'm trying to put a value from my database. However, I'm very new to this and cant quite figure out the logic for doing it. Below is my code.
Can anyone please tell me how I can get the three IDs in each of the columns and if there are more than three IDs how I do it on a new row etc.
Code: Select all
<div class="col1">
<!-- Column 1 start -->
<?php
$sqlstr = mysql_query("SELECT * FROM `products` WHERE `accessories` = '1'");
if (mysql_numrows($sqlstr) != 0) {
while ($row = mysql_fetch_array($sqlstr)) {
?>
<?= row['photo_mid'] ?>"
<!-- Column 1 end -->
</div>
<div class="col2">
<!-- Column 2 start -->
<h2>This is col 2</h2>
<?= row['photo_mid'] ?>"
<!-- Column 2 end -->
</div>
<div class="col3">
<!-- Column 3 start -->
<h2>This is col 3</h2>
<?= row['photo_mid'] ?>"
<!-- Column 3 end -->
</div>