diff --git a/market.php b/market.php index 05078a6..31cf00d 100644 --- a/market.php +++ b/market.php @@ -21,7 +21,12 @@ if (!$compare) { } ?>

Marketplace

-

You can buy and sell items by clicking on the market in depot.
To sell an item: Place item inside your depot, click on market, search for your item and sell it.

+

You can buy and sell items by clicking on the market in depot.
To sell an item: Place item inside your depot, click on market, search for your item and sell it.

+

WTS: Want to sell

@@ -79,15 +84,30 @@ if (!$compare) { 0) ? (int)$compare : getValue($compare); + $condition = "`itemtype`='$compare'"; + + if (is_string($compare)) { + $query = array(); + foreach ($items as $id => $name) { + if (strpos(strtolower($name), strtolower($compare)) !== false) { + $query[] = $id; + } + } + $condition = "`itemtype` IN (". implode(',', $query) .")"; + } + // First list active bids - $offers = mysql_select_multi("SELECT `mo`.`id`, `mo`.`sale`, `mo`.`itemtype` AS `item_id`, `mo`.`amount`, `mo`.`price`, `mo`.`created`, `mo`.`anonymous`, `p`.`name` AS `player_name` FROM `market_offers` AS `mo` INNER JOIN `players` AS `p` ON `mo`.`player_id`=`p`.`id` WHERE `mo`.`itemtype`='$compare' ORDER BY `mo`.`price` ASC;"); - $historyOffers = mysql_select_multi("SELECT `id`, `itemtype` AS `item_id`, `amount`, `price`, `inserted`, `expires_at` FROM `market_history` WHERE `itemtype`='$compare' AND `state`='255' ORDER BY `price` ASC;"); + $offers = mysql_select_multi("SELECT `mo`.`id`, `mo`.`sale`, `mo`.`itemtype` AS `item_id`, `mo`.`amount`, `mo`.`price`, `mo`.`created`, `mo`.`anonymous`, `p`.`name` AS `player_name` FROM `market_offers` AS `mo` INNER JOIN `players` AS `p` ON `mo`.`player_id`=`p`.`id` WHERE `mo`.$condition ORDER BY `mo`.`price` ASC;"); + $historyOffers = mysql_select_multi("SELECT `id`, `itemtype` AS `item_id`, `amount`, `price`, `inserted`, `expires_at` FROM `market_history` WHERE $condition AND `state`='255' ORDER BY `price` ASC;"); $buylist = false; + // Markup + $itemname = (isset($items[$compare])) ? $items[$compare] : $compare; + if (!is_string($compare)) echo "

Comparing item: ". $itemname ."

"; + else echo "

Search: $compare

"; ?> -

Comparing item

Active offers