I have this code but in my opinion it's too many lines. I'm new into programming so that's why I have questions. I think there should be a shorter way to make it work without this if else loop, switch or is it ok like it's now?
if $total==21
then mysql_query("UPDATE user SET left = '20'
, $total==20
then left=19
and so on until the $total=1
and left=0
.
if ($total==21 )
{
mysql_query("UPDATE `user` SET `left` = '20' WHERE `user` = 'user1' ") or die(mysql_error() );
}
else if ($total==20)
{
mysql_query("UPDATE `user` SET `left` = '19' WHERE `user` = 'user1' ") or die(mysql_error() );
}
....
else if ($total==1)
{
mysql_query("UPDATE `user` SET `left` = '0' WHERE `user` = 'user1' ") or die(mysql_error() );
}
else {
echo nl2br("0 left");
}
Merry Christmas !