$count = 0; $short = 1; //Table header if ($result) { echo '<p id="phpresdesc">For generations, the name Deco Lighting has been synonymous with contemporary design and an extraordinary quality of illumination. Through our continuing research into how light influences a space and the people who inhabit it, Deco Lighting products are engineered for superior results. <br><br> Ingenious, technologically advanced luminaires control and emit a remarkably soft, natural light, offering a refined balance of visual comfort, dimensionality and drama within an architectural setting.</p>'; echo '<div class="phpresbar">'; //Fetch and print while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { echo '<div class="phprestn">'; echo "$count $short"; $short = 0; echo ' <a class="model arc" href="product.php?id=' . $row['id'] . '">'.$row['model'].'</a><br> <a href="product.php?id=' . $row['id'] . '"><img src="' . $row['tn'] . '" alt="'.$row['model'].'"></a><br>'; echo '<a class="tinydesc" href="product.php?id=' . $row['id'] . '">'.$row['tinydesc'].'</a> </div> '; $count++; if ($count == "4" or $count == "8") { echo '</div><br><div class="phpresbar">'; $short = 1; } if ($count == "12") { echo '</div><br>'; $short = 1; } } if ($short == "0") { echo '</div></br>'; }