Im making a game while trying to learn php and as a way to augment weapons and armour im adding gems to the game rubys diamonds emeralds and crystals and im making super gems (more poewerful) and master gems (most powerful)
and using this script im converting regular gems to super gems i got rubys to do it fairly easy but when i started trying to do the diamonds it just tell me i dont have neough gems though i have 1 million in my database. I need help figuring out why this isnt working i tried using if statements and a switch and this is my current code for the converter its pretty simeple but im just missing something.
<?
$sruby='super ruby';
$gem=$_POST['start'];
$type=$_POST['finish'];
$result=mysql_query("SELECT * FROM items WHERE username='".$_SESSION['username']."'");
while($row = mysql_fetch_array($result))
$ruby=$row['ruby'];
$diamond=$row['diamond'];
$emerald=$row['emerald'];
$crystal=$row['crystal'];
switch (true) {
case $gem==ruby:
if($type=='super' && $ruby>='500'){
mysql_query("UPDATE items SET ruby=ruby-500 WHERE username='".$_SESSION['username']."'");
mysql_query("UPDATE items SET sruby=sruby+1 WHERE username='".$_SESSION['username']."'");
echo('You have just converted your 500 rubies to 1 super ruby');
}
else{
echo('You do not have enough rubies');
}
break;
case $gem==diamond:
if($type=='super' && $diamond>='500'){
mysql_query("UPDATE items SET sdiamond=sdiamond+1");
Echo("YOu converted 500 diamonds to 1 super diamond");
}
else{echo("You do not have enough diamonds");}
break;
}
?>