Jump to content

case problem.


grlayouts

Recommended Posts

When i try and sell drugs using the below it works. however when i try and sell steaks it comes up sorry you dont have enough drugs?

 

<?php
print "<form method=post action=cmarket.php?view=sell&step=sell>Sell <input name=amount><select name=seller><option value=drugs>Drugs</option><option value=steak>Steaks</option></select>. <input type=submit value=Sell></form>";
if (isset($_POST)){
switch($_POST['seller'])
{
	case "drugs":
		if ($stat['drugs'] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set drugs=(drugs-$amount) where id=".$stat[id]);
			mysql_query("update players set credits=credits+($amount*".$stat['drugprice'].") where id=".$stat['id']);
			print "You sold $amount of drugs."; 
			}
			break;
					case "steak":
		if ($stat['drugs'] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set steaks=(steaks-$amount) where id=".$stat[id]);
			mysql_query("update players set credits=credits+($amount*".$stat['steakprice'].") where id=".$stat['id']);
			print "You sold $amount of steaks."; 
			}

}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/47363-case-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.