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"); Quote Link to comment 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; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.