' . mysql_error()); db_close; $category_name = mysql_result($category_result, 0, 'category'); require(D_INCLUDES_PATH.'doctype.php'); ?> Products
Add Product To This Category >>'; } $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 ''; // PRODUCT DESCRIPTION CELL echo ''; $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 '
'; if (!$fetched['image']) { echo ''; } else { echo '' . $fetched['name'] . '
Enlarge

'; } echo '
Name: ' . $fetched['name'] . ' '; if ($_SESSION['admin_access_level'] == 1) { echo '  - Edit'; echo '  |  Delete'; } echo '
Description: ' . $fetched['description'] . '
Price: $' . $fetched['price'] . '

Add to CartAdd to Cart

'; } else { echo '
'; } if ($total_rows > $maxRows_result) { if ($products_rows > ($maxRows_result/2)) { echo '
'; for ($i = $totalPages_result; $i >= 1; $i--) { $page_link_class = ($pageNum_result == $i) ? 'pagenum-active' : 'pagenum'; echo ' ' . $i . ' '; } echo '
'; } } } else { echo 'Currently, there are no items in this category.'; } ?>