tabular data
Posted: Wed Mar 15, 2006 4:20 pm
Hi,
I am trying to display a list of products in a table. The code below displays data from a mysql database row-by-row.
However, I would like to be able to display the products row-by-row but instead of displaying one product per row i would like to display more than one product per row.
Here is the code i currently use to display row-by-row data:
Thanks.
I am trying to display a list of products in a table. The code below displays data from a mysql database row-by-row.
However, I would like to be able to display the products row-by-row but instead of displaying one product per row i would like to display more than one product per row.
Here is the code i currently use to display row-by-row data:
Code: Select all
<?php
//include "auth.inc.php";
//include "b2b_header.php";
//CONNECT TO SERVER AND DATABASE
include "conn.inc.php";
$query = "SELECT * FROM product" ;
$result = mysql_query($query)
or die(mysql_error());
?>
<html>
<head>
<title>Product List</title>
</head>
<body>
<table>
<tr>
<td width="10%">Product Code</td>
<td width="20%">Name</td>
<td width="20%">Description</td>
<td width="30%">Image</td>
<td width="10%">Price</td>
<td width="10%">Stock</td>
</tr>
<?php
while ($row = mysql_fetch_array($result)) {
extract($row);
echo "<tr><td width=\"10%\">";
echo $prod_code;
echo "</td><td width=\"20%\">";
echo $prod_name;
echo "</td><td width=\"20%\">";
echo $prod_description;
echo "</td><td width=\"30%\">";
echo $prod_image;
echo "</td><td width=\"10%\">";
echo $prod_unit_price;
echo "</td><td width=\"10%\">";
echo $prod_stock_qty;
echo "</td></tr>";
}
?>
</table>
</body>
</html>