echo page_title('Catalog : ' . $category_name); ?>
if ($_SESSION['admin_id'] != '')
{
echo '';
}
$maxRows_result = 5;
$pageNum_result = 1;
if (isset($_GET['page']))
{
$pageNum_result = $_GET['page'];
}
$startRow_result = ($pageNum_result - 1) * $maxRows_result;
// Compose SQL command
$products_sql = "
SELECT p.id, p.id2, p.name, p.description, p.price, p.image
FROM products p
WHERE category_id = $category_id AND active = 1
ORDER BY p.name
LIMIT $startRow_result,$maxRows_result
";
$total_products_sql = "
SELECT COUNT(id) AS count
FROM products
WHERE category_id = $category_id AND active = 1
";
db_connect();
$products_result = @mysql_query($products_sql) or die('Could not get products list. ' . mysql_error());
$products_rows = @mysql_num_rows($products_result);
$result_total = mysql_query($total_products_sql);
db_close;
$total_rows = mysql_result($result_total, 0, 'count');
$totalPages_result = ceil($total_rows/$maxRows_result);
$orderNum = isset($startRow_result) ? $startRow_result : 0;
$queryString_result = '';
if ($total_rows > 0)
{
echo '
Products in this category: ' . $total_rows . ' |
';
if ($total_rows > $maxRows_result)
{
for ($i = $totalPages_result; $i >= 1; $i--)
{
$page_link_class = ($pageNum_result == $i) ? 'pagenum-active' : 'pagenum';
echo ' ' . $i . ' ';
}
}
echo ' |
';
echo '';
$display = 1; // How many per row
$cols = 0;
while ($fetched = mysql_fetch_array($products_result))
{
$image = explode('.',$fetched['image']);
$image_thumb = $image[0] . '-th.' . $image[1];
if ($cols == 0)
{
echo '';
}
// IMAGE CELL
echo '
';
if (!$fetched['image'])
{
echo ' ';
}
else
{
echo '![' . $fetched['name'] . '](' . D_WEB_ROOT . 'catalog/images/' . $image_thumb . ') Enlarge
';
}
echo ' | | ';
// PRODUCT DESCRIPTION CELL
echo '
| Name: |
' . $fetched['name'] . ' ';
if ($_SESSION['admin_access_level'] == 1)
{
echo ' - Edit';
echo ' | Delete';
}
echo ' |
| Description: |
' . $fetched['description'] . ' |
| Price: | $' . $fetched['price'] . ' |
Add to Cart
| ';
$cols++;
if ($cols < $display)
echo ' | ';
if ($cols == $display)
{
echo '
| ';
$cols = 0;
}
}
// added the following so it would display the correct html
if($cols != $display && $cols != 0)
{
$neededtds = $display - $cols;
for($i=0;$i<$neededtds;$i++)
{
echo ' | ';
}
echo ' ';
}
else
{
echo ' |