My current coding for the php scripting is below, this is called on in the HTML code by <?php echo $dynamicList; ?>
Code: Select all
<?php
// run a select query to get the latest 6 items
include "storescripts/connect_to_mysql.php";
$dynamicList="";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");
$productCount = mysql_num_rows ($sql); // count the output amount
if ($productCount > 0){
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$sku = $row["sku"];
$product_name = $row["product_name"];
$price = $row["price"];
$dynamicList .=
'<table width="100" border="0" cellpadding="3">
<tr>
<td align="left" valign="top"><a href="product.php?id=' .$id. '"><img src="inventory_images/' .$id. '.jpg" alt="$product_name" width="125" border="0"/></a>
</td>
</tr>
<tr>
<td align="left" valign="top">' .$product_name. '</td>
</tr>
<tr>
<td align="left" valign="top">£' .$price. '</td>
</tr>
</table> ';
}
} else {
$dynamicList = "You have no products listed in our store yet" ;
}
mysql_close();
?>
Thanks in advance