i want to display my sql database products in three columns …
any help is highly appreciated…
[php]<?php
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
?>
<?php
// Run a select query to get my letest 6 items
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 0,4");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList .= '
';
}
} else {
$dynamicList = "We have no products listed in our store yet";
}
mysql_close();
?>
<?php
// Run a select query to get Next 6 items
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$dynamicList1 = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC limit 5,8");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList1 .= '
';
}
} else {
$dynamicList1 = "We have no products listed in our store yet";
}
mysql_close();
?>
<?php
// Run a select query to get my Next 6 items in the third column.
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$dynamicList2 = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 9,12");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList2 .= '
';
}
} else {
$dynamicList2 = "We have no products listed in our store yet";
}
mysql_close();
?>[/php]
[code]
Store Home Page
<?php include_once("template_header.php");?>
Health Category
<?php echo $dynamicList; ?>
|
<?php echo $dynamicList1; ?>
|
<?php echo $dynamicList2; ?>
|
<?php include_once("template_footer.php");?>
[/code]