"); exit(); } } $categoryId = $HTTP_POST_VARS['category']; if ($categoryId == null) { $categoryId = $HTTP_GET_VARS['category']; if ($categoryId == null) { printError($scriptName, $startTime, "Search Items By Category", "You must provide a category identifier!
"); exit(); } } $page = $HTTP_POST_VARS['page']; if ($page == null) { $page = $HTTP_GET_VARS['page']; if ($page == null) $page = 0; } $nbOfItems = $HTTP_POST_VARS['nbOfItems']; if ($nbOfItems == null) { $nbOfItems = $HTTP_GET_VARS['nbOfItems']; if ($nbOfItems == null) $nbOfItems = 25; } getDatabaseLink($link); beginRO($link); function searchitemsbycategory($link, $categoryName, $categoryId, $page, $nbOfItems) { printHTMLheader("RUBiS: Items in category $categoryName"); print("

Items in category $categoryName



"); txcache_invaltag("items", "category", $categoryId); $now = virtualTimeSQL(); $result = sql_query("SELECT items.id,items.name,items.initial_price,items.max_bid,items.nb_of_bids,items.end_date FROM items WHERE category=$categoryId AND end_date>='$now' ORDER BY items.id LIMIT $nbOfItems OFFSET ".$page*$nbOfItems, $link) or die("ERROR: Query failed"); if (sql_num_rows($result) == 0) { if ($page == 0) print("

Sorry, but there are no items available in this category !

"); else { print("

Sorry, but there are no more items available in this category !

"); print("

\nPrevious page\n
\n"); } sql_free_result($result); return; } else { print("". "". ""); } while ($row = sql_fetch_array($result)) { $maxBid = $row["max_bid"]; if ($maxBid == 0) $maxBid = $row["initial_price"]; print("
DesignationPriceBidsEnd DateBid Now". "
".$row["name"]. "$maxBid". "".$row["nb_of_bids"]. "".$row["end_date"]. ""); } print("
"); if ($page == 0) print("

\nNext page\n
\n"); else print("

\nPrevious page\n   ". "Next page\n\n
\n"); sql_free_result($result); } wrap(true, 'searchitemsbycategory', $link, $categoryName, $categoryId, $page, $nbOfItems); commit($link); sql_close($link); printHTMLfooter($scriptName, $startTime); ?>