Switch statement returning multiple values
Posted: Sat Nov 25, 2006 7:46 am
I have a switch statement which checks conditions for values in a MySQL DB and should returned 'Unavailable' if a value is 0 and 'Available' if a value is 1. But at the moment the first check runs fine but the rest return both results. Can somebody help me please.
My code is:
'Lowloader' only show Available, as expected. But the rest show both 'Available' and 'Unavailable'.
Regards,
My code is:
Code: Select all
switch ($res) {
case ($res['lowloader'] == 0):
echo "Lowloader: <b>Unavailable</b><br>";
case ($res['lowloader'] == 1):
echo "Lowloader: <b>Available</b><br>";
case ($res['articflatbed'] == 0):
echo "Artic flatbed: <b>Unavailable</b><br>";
case ($res['articflatbed'] == 1):
echo "Artic flatbed: <b>Available</b><br>";
case ($res['car'] == 0):
echo "Car: <b> Unavailable</b><br>";
case ($res['car'] == 1):
echo "Car: <b> Available </b><br>";
case ($res['vantauliner'] == 0):
echo "Vantauliner: <b> Unavailable</b><br>";
case ($res['vantauliner'] == 1):
echo "Vantauliner: <b> Available</b><br>";
case ($res['vanlwb'] == 0):
echo "Vanlwb: <b> Unavailable </b><br>";
case ($res['vanlwb'] == 1):
echo "Vanlwb: <b> Available </b><br>";
case ($res['vanswb'] == 0):
echo "Vanswb: <b> Unavailable </b><br>";
case ($res['vanswb'] == 1):
echo "Vanswb: <b> Available </b><br>";
case ($res['tautliner75t'] == 0):
echo "Tautliner75: <b> Unavailable </b><br>";
case ($res['tautliner75t'] == 1):
echo "Tautliner75: <b> Available </b><br>";
case ($res['box75t'] == 0):
echo "Box75t: <b> Unavailable </b><br>";
case ($res['box75t'] == 1):
echo "Box75t: <b> Available </b><br>";
case ($res['vanmwb'] == 0):
echo "Vanmwb: <b> Unavailable </b><br>";
case ($res['vanmwb'] == 1):
echo "Vanmwb: <b> Available </b><br>";
}Regards,