june_c21 Posted December 18, 2007 Share Posted December 18, 2007 hi, can someone help me to figure out what's wrong with this code. thanks $query = "SELECT unit FROM report " ; $result = mysql_query($query,$dblink); while($row = mysql_fetch_array($result)) { $unit = $row[0]; } if($unit==GF1) { // echo "this is Role #1" $redirect = 'sort_gf1.php' ; } elseif($unit==2) { $redirect = 'champ.html'; } elseif($unit==3) { $redirect = 'champ.html'; } else { $redirect = 'view1.php'; } header ("Location: $redirect"); Link to comment https://forums.phpfreaks.com/topic/82141-solved-if-else/ Share on other sites More sharing options...
~n[EO]n~ Posted December 18, 2007 Share Posted December 18, 2007 You can try with switch too... <?php $query = "SELECT unit FROM report " ; $result = mysql_query($query,$dblink); while($row = mysql_fetch_array($result)) { $unit = $row[0]; } switch ($unit) { case "GF1": header ("Location: sort_gf1.php"); break; case "2": header ("Location: champ.html"); break; case "3": header ("Location: champ.html"); break; default: header ("view1.php"); break; } ?> Link to comment https://forums.phpfreaks.com/topic/82141-solved-if-else/#findComment-417417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.