Hello all,
I am working on an ecommerce site ( does not involve prices though, for wholesale) and I am trying to find my way out as a newbie in php mysql world.
Here is my code;
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
// Run a select query to get all products
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
// SQL query to interact with info from our database
$sql = mysql_query("SELECT id, product_name, date_added FROM products ORDER BY date_added DESC LIMIT 12");
$i = 0;
// Establish the output variable
$dyn_table = '<table border="1" cellpadding="10">';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$photo .= '<a href="product.php?id=' . $id . '"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" />' . $product_name . '<br /><a href="product.php?id=' . $id . '">View Product Details</a>';
if ($i % 4 == 0) { // if $i is divisible by our target number (in this case "3")
$dyn_table .= '<tr><td>' . $photo . '</td>';
} else {
$dyn_table .= '<td>' . $photo . '</td>';
}
$i++;
}
$dyn_table .= '</tr></table>';
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Home Page</title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="wrap">
<?php include_once("template_header.php");?>
<div id="intro">
<?php echo $dyn_table; ?>
</div>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>
and it displays this; Store Home Page
what I’d like to do is to display 4 columns and 3 rows ( 12cells) per page and have pagination( for multiple pages) as previous, next, page numbers.
Also I’d like to place a check box in each product cell to direct an inquiry by form email.
Would also like to place a database search on the site.
I am trying to do it by myself but no luck yet. Any help would be appreciated.
thank you,