Jump to content

Anything wrong with if else structure?


gammaman

Recommended Posts

Is there anything wrong with what I am trying to do, because it seems that the elseif or else are never reached.  The if (first statment) works fine.

 

<?php

  $conn=mysql_connect("localhost","fierm","13183");

  if(!$conn){
   echo "failed";
}else{
   mysql_select_db(fierm);

   $Amt=$_POST['amt'];
   $Item=$_POST['new'];
   
   echo "$Amt";
   echo "$Item";

   $result=mysql_query("select InventoryLevel from Inventory where ProductID='$Item'AND InventoryLevel");  
   $cou=mysql_num_rows($result);
   
   echo "$cou";

   if (InventoryLevel > $Amt )
   {
     
     mysql_query("Insert into CustomerOrder (ProductID,Amount) Values ('$Item','$Amt')")or die(mysql_error());
     mysql_query("Update  Inventory set InventoryLevel = InventoryLevel-'$Amt' 
                   Where ProductID='$Item'"); 

   }

   elseif (InventoryLevel == $Amt )
   {
      mysql_query("Insert into CustomerOrder (ProductID,Amount) Values ('$Item','$Amt')")or die(mysql_error());
      mysql_query("Delete From Inventory ProductID,Amount where ProductID='$Item' and Amount='$Amt'");   


   }


   else
   {
      echo "Sorry Not Enough Items";
   }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/103042-anything-wrong-with-if-else-structure/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.