Mysql php code does not display what I'd like

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;

// Script Error Reporting
ini_set('display_errors', '1');
// 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>';
$dyn_table .= '</tr></table>';

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<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" />

<div id="wrap">
  <?php include_once("template_header.php");?>
  <div id="intro">
  <?php echo $dyn_table; ?>
  <?php include_once("template_footer.php");?>

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, :frowning:

Well, Step 1 is to take it 1 step at a time :stuck_out_tongue:

Lets focus on getting the items to display without cascading first.

$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>’;

I spy with my little eye an errant period…

Thanks StarLion. Good eye. Now I have to work on the rest of the plan.

cheers :slight_smile: