Displaying data in 3 columns
Posted: Wed Oct 24, 2007 11:00 am
I have a database with products in and I want ti to automatically show every product on the page. Now I am able to do this easy enough but what I am struggling to do is that I want the products to be displayed in 3 columns. I can get them to display one under the other easy enough but I want them to be in rows with 3 columns instead.
Can anyone please help.
Cheers
Wardy
Can anyone please help.
Code: Select all
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM products ORDER BY price LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("Products are missing! Ooops!");
}
$bgcolor = "#FFFFFF"; //
$bgcolor2 = "#BFDFFF"; //
$bgcolor3 = "#FFCC33"; //
$bgcolor4 = "#FFDF80"; //
$bgcolor5 = "#FFEEB9"; //
$font = "Verdana, Arial, Helvetica, sans-serif"; //
$fontsize = "2"; //
$tdwidth = "170"; //
$tdwidth2 = "120"; //
$tdwidth3 = "145"; //
echo('<table width="760" border="0" cellspacing="1" cellpadding="5" align="center" bgcolor="#3333FF"><tr valign="top" bgcolor="#FFFFFF">');
while($row = mysql_fetch_array($result)){
if ($bgcolor == "#FFFFFF"){
$bgcolor = "#FFFFFF";
}else{
$bgcolor = "#FFFFFF";
}
echo('<td width="240">');
echo("<font face=".$font.">");
echo("<font size=".$fontsize.">");
echo($row["name"]);
echo("<br>");
echo('<img src="' . $row["smallimage"] . '">');
}
echo("</table>");
?>Wardy