I have the following code:
$result = mysql_query("select * from ${db_name}_users limit 1");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
if ($player[$ships_killed] == 1)
echo "1";
else if ($player[$ships_killed] == 2)
echo "2";
else if ($player[$ships_killed] == 3)
echo "3";
else if ($player[$ships_killed] == 4)
echo "4";
else if ($player[$ships_killed] == 5)
echo "5";
else if ($player[$ships_killed] =< 10)
echo "10";
else if ($player[$ships_killed] =< 15)
echo "15";
else if ($player[$ships_killed] =< 20)
echo "20";
else
echo "Over Range";
}
I’m having a hard time with the less than or equal signs, it doesnt show the proper value. For example, when the field shows “11” it instead echos “Over Range”.
My problem is that specific field grows a lot and I cannot cover every single value with an equals case.
The numbered values will eventually be replaced with an image such as echo "<img src='img/badges/1i.png' />"; therefore I don’t want to echo the value directly.
Is there a workaround this?
First issue is the
=<sign, which is wrong. Try using<=instead.Also, instead of using nested if’s, you could use a switch statement, maybe with a counter.
Teslo.