"); exit(); } } $categoryId = $HTTP_POST_VARS['category']; if ($categoryId == null) { $categoryId = $HTTP_GET_VARS['category']; if ($categoryId == null) { printError($scriptName, $startTime, "Search Items By Region", "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 itemsbyrcImpl($link, $regionId, $categoryId, $nbOfItems) { txcache_invaltag("itemsrc", "rc", $regionId."-".$categoryId); $now = virtualTimeSQL(); $result = sql_query("SELECT itemId FROM items_by_rc WHERE category=$categoryId AND region=$regionId AND end_date>='$now' ORDER BY itemId LIMIT $nbOfItems OFFSET ".$page*$nbOfItems, $link) or die("ERROR: Query failed"); $x = pg_fetch_all($result); sql_free_result($result); return $x; } function itemsbyrc($link, $regionId, $categoryId, $nbOfItems) { return wrap(true, 'itemsbyrcImpl', $link, $regionId, $categoryId, $nbOfItems); } function searchitemsbyregion($link, $regionId, $categoryId, $page, $nbOfItems) { printHTMLheader("RUBiS: Search items by region"); print("

Items in category $categoryName



"); // $result = sql_query("SELECT items.id,items.name,items.initial_price,items.max_bid,items.nb_of_bids,items.end_date FROM items,users WHERE items.category=$categoryId AND items.seller=users.id AND users.region=$regionId AND end_date>=NOW() ORDER BY items.id LIMIT $nbOfItems OFFSET ".$page*$nbOfItems, $link) or die("ERROR: Query failed"); $rcRes = itemsbyrc($link, $regionId, $categoryId, $nbOfItems); if (empty($rcRes)) { if ($page == 0) print("

Sorry, but there is no item in this category for this region.


\n"); else { print("

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

"); print("

\nPrevious page\n
\n"); } return; } else print("". "". ""); foreach ($rcRes as $rcrow) { $itemId = $rcrow["itemid"]; $row = getItem($link, $itemId); $maxBid = $row["max_bid"]; if (($maxBid == null) ||($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"); } wrap(true, 'searchitemsbyregion', $link, $regionId, $categoryId, $page, $nbOfItems); commit($link); sql_close($link); printHTMLfooter($scriptName, $startTime); ?>