} else { ?> <tr> <td width="800" colspan="5" align="center">There are no ships in this order.</td> </tr> <? } ?> </form> </table> <br> Add ships to the order list <table border="0" width="753"> <? $baseships = getBaseShips($playerdata['id'], $ship_id); $fleetships = getFleetShips($playerdata['id'], $fleet_id, $ship_id); ?> <form name="order_form" method="POST" action="main.php?mod=market&act=sell&do=editorder&order_id=<?php echo $order_id; ?> "> <tr> <td background="img/bg_balk.jpg"><b>Ship name</b></td> <td background="img/bg_balk.jpg" align="center"><b>Amount at base</b></td> <td width="177" background="img/bg_balk.jpg" align="center"></td> <td width="103" background="img/bg_balk.jpg" align="center"><b>Amount to sell</b></td> <td width="95" background="img/bg_balk.jpg" align="center"></td> </tr> <tr> <td>
$order_id = secureData($_POST['order_id']); $seller_id = secureData($_POST['seller_id']); if (checkSteelResource($playerdata['id'], $cost_steel) && checkCrystalResource($playerdata['id'], $cost_crystal) && checkErbiumResource($playerdata['id'], $cost_erbium) && checkTitaniumResource($playerdata['id'], $cost_titanium)) { $sql_updres = "UPDATE $table[players] SET `res_steel` = `res_steel` - '$cost_steel', `res_crystal` = `res_crystal` - '$cost_crystal', `res_erbium` = `res_erbium` - '$cost_erbium', `res_titanium` = `res_titanium` - '$cost_titanium' WHERE `id` = '$playerdata[id]'"; mysql_query($sql_updres) or die(mysql_error()); $sql_updres2 = "UPDATE $table[players] SET `res_steel` = `res_steel` + '$cost_steel', `res_crystal` = `res_crystal` + '$cost_crystal', `res_erbium` = `res_erbium` + '$cost_erbium', `res_titanium` = `res_titanium` + '$cost_titanium' WHERE `id` = '$seller_id'"; mysql_query($sql_updres2) or die(mysql_error()); $sql_getorderships = "SELECT `order_id`, `ship_id`, `amount` FROM $table[market_ships] WHERE `order_id` = '$order_id'"; $rec_getorderships = mysql_query($sql_getorderships); while ($res_getordership = mysql_fetch_array($rec_getorderships)) { $baseships = getBaseShips($playerdata['id'], $res_getordership['ship_id']); if ($baseships == 0){ $sql_insertship = "INSERT INTO `$table[playerunit]` (`player_id`, `type_id`, `unit_id`, `amount`) VALUES ('$playerdata[id]', '3', '$res_getordership[ship_id]', '$res_getordership[amount]')"; mysql_query($sql_insertship) or die(mysql_error()); }else{ $sql_updships = "UPDATE $table[playerunit] SET `amount` = `amount` + '$res_getordership[amount]' WHERE `player_id` = '$playerdata[id]' AND `unit_id` = '$res_getordership[ship_id]'"; mysql_query($sql_updships) or die(mysql_error()); } $sql_delships = "DELETE FROM $table[market_ships] WHERE `order_id` = '$order_id' AND `ship_id` = '$res_getordership[ship_id]'"; mysql_query($sql_delships) or die(mysql_error()); } $sql_delorderships = "DELETE FROM $table[market] WHERE `id` = '$order_id'"; mysql_query($sql_delorderships) or die(mysql_error());