0
<?php
session_start();
include "conn.php";
if (isset($_POST['submit']) && $_POST['billno']!='' ) 
{
   $bill = $_POST['billno'];
  $query = mysql_query("SELECT bill_no, tag_no FROM tbl_cargo_details WHERE bill_no='$bill' or tag_no ='$bill'")
   or die(mysql_error());
   while ($row = mysql_fetch_assoc($query))
    {   
     if($bill == $row['bill_no'] || $bill == $row['tag_no'])
         {
            header("location:true.php?bill=$bill");
         }
        else
          {
            header("location:false.php?bill=$bill");
          }
}

else
{
?>
i am not able to get the false page location when the condition fails. it only points to the first header location. i think first header is not passing the control when the condition is false. can any one help me out with this. Thanks..
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Biiim
1

Hi,

I think that you dont need the while loop because an if is more than enough :)
Try this :

 $query = mysql_query("SELECT bill_no, tag_no FROM tbl_cargo_details WHERE bill_no='$bill' or tag_no ='$bill'")
 or die(mysql_error());

 $num_rows = mysql_num_rows($query);

 if($num_rows > 0){ 

      // we are sure here that $bill == $row['bill_no'] or $bill == $row['tag_no'] 

      header("location:true.php?bill=$bill");  

 }else{

     // our mysql request has return 0 results

     header("location:false.php?bill=$bill");

 }
Votes + Comments
good
1

Akmozo's should work, the problem is while ($row = mysql_fetch_assoc($query)) as when it finds nothing, it won't loop

Votes + Comments
thank you so so much... u saved me..
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.