jeudi 28 novembre 2019

How to write php If statement for multiple conditions true (Condition#1=true, Condition#2=true, Condition#3=true)

I have a form with FromDate , ToDate, VendorName and GoodsName, i need to show the result once everything is true(i.e. FromDate="11/20/2019", ToDate="11/28/2019", VendorName="Abdullah" and GoodsName="Wheat"), here is my code

if ( ($vendor_name == $vendor_name) && ($snack_name == $snack_name) &&  ($start_Date == $start_Date)) {
  $sql = "SELECT * FROM t_purchase WHERE from_vendor ='$vendor_name' AND goods_name ='$snack_name' AND date BETWEEN '$start_Date' AND '$end_Date'";
  $result = $con->query($sql);

  if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {

     $data = '<tr><td>' .$row["id"]. '</td><td>' .$row["date"]. '</td><td>' .$row["goods_name"]. '</td><td>' .$row["from_vendor"]. '</td><td>' .$row["no_kgs"]. '</td><td>' .$row["rate_of"]. '</td><td>' .$row["bill_rate"]. '</td><td>' .$row["now_paid"]. '</td><td>' .$row["v_balance"]. '</td></tr>';
     echo $data;
    }
  } 
 else {
    echo "0 results";
 }
}

Aucun commentaire:

Enregistrer un commentaire