Forum Moderators: coopster
<?php
$sql = "select wallpaperid from wallpaper";
$result = mysql_query($sql ,$db);
if ($myrow = mysql_fetch_array($result)) {
do {
printf("<td><a href='%s'><img src='images/sample/%s.jpg' border='0'></td>", $myrow["wallpaperid"], $myrow["wallpaperid"]);
} while ($myrow = mysql_fetch_array($result));
}
?>
if i have 6 pictures in database it will show like this
Image1.gif
Image2.gif
Image3.gif
Image4.gif
Image5.gif
Image6.gif
but i want it show the result like this in table
Image1.gif Image2.gif Image3.gif Image4.gif
Image5.gif Image6.gif
$sql = "select * from sometable";
$result = mysql_query($sql);
$tdcount = 1;
$numtd = 3; // number of cells per row
echo "<table>";
while($row = mysql_fetch_array($result)) {
if ($tdcount == 1) echo "<tr>";
echo "<td>some stuff: $tdcount</td>"; // display as you like
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo "</tr>";
}
echo "</table>";