grlayouts Posted June 13, 2008 Share Posted June 13, 2008 I have a market game that depending on the ammount of product on the market depends on the price. but here's the thing what i want it to do 1. it keep the price of the drugs between 100-200 2. if someone sells another product for example steaks it boosts the price for everything. the code works but i dont know how to acheive what i want. <? include('config.php'); $q2 = mysql_fetch_row(mysql_query("SELECT SUM(drugs) FROM players;")); function price ($q) { if ($q > 1000000) return 25; return ceil($q * -275 / 1000000) + 300; } $qtys = $q2; foreach ($qtys as $q) { echo "$q :" . price($q) . '<br>'; } mysql_query('UPDATE players SET drugs = drugs + (drugfact*2), dpayout = (drugfact*2);'); mysql_query('UPDATE players SET credits = credits - (employees*wages)'); $sql = "UPDATE price SET cost = $q where ITEM = 'drugs'"; mysql_query($sql) or die($sql . ' : ' . mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/110134-stocks/ Share on other sites More sharing options...
cooldude832 Posted June 20, 2008 Share Posted June 20, 2008 so if someone sells prodcut_id 15 all other products go up so simple is to do an update query using math in the query to update the price is it is price+random number. Read mysql math functions the where clause is where Product_Id != SOLD ITEM Link to comment https://forums.phpfreaks.com/topic/110134-stocks/#findComment-569886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.