<?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..

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");

 }
commented: good +5

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

commented: thank you so so much... u saved me.. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.