Jump to content

if statement


spearchilduser

Recommended Posts

$sql = mysql_query("SELECT * FROM quotes

WHERE (Firm_By_Customer=0 OR Firm_By_Customer=$userid) AND Firm_ID=0");

while($row = mysql_fetch_array($sql)){

$qid = $row["Quote_ID"];

$sq2 = mysql_query("SELECT * FROM bids

WHERE (Firm_ID=$id AND Quote_ID=$qid AND DeclienedByCustomer=1) OR (Firm_ID=$id AND Quote_ID=$qid)");

if(!mysql_fetch_array($sq2)){

$customer_Location = $row["Customer_Location"];

$customer_Destination = $row["Customer_Destination"];

$how_Many = $row["How_Many"];

$wait_Time = $row["Wait_Time"];

$pric = $row['Price'];

echo '<table border="0">

<tr>

<td>Customer Location </td><td><input readonly type= "text" name="Customer_Location" value="'.$customer_Location.'"></td>

<td>Customer Destination</td><td> <input readonly type= "text" name="Customer_Destination" value="'.$customer_Destination.'"></td>

<td>Customer can Wait</td><td> <input readonly type= "text" name="mins" maxlength="2" value="'.$wait_Time.' Minutes."></td>

<td>Customer are</td><td width="2px"> <input readonly type= "text" name="numb" value="'.$how_Many.' People."></td>

<td>Price</td><td> <input readonly type= "text" name="price" value="'.$pric.'"></td>

<td><a href="TaxiEntry1.php?Quote_ID='.$qid.'">Accept</a>  <a href="decline.php?Quote_ID='.$qid.'">Decline</a></td>

</tr>

</table><br />';}

} // close while

?>

</body>

</html>

 

is my code the user is accepting a job by clickign accept or declinign by selecting decline and i need to update the accept_decline field dependant on which link they choose

 

 

Link to comment
https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329124
Share on other sites

then adapt each link to include a flag for accept/decline and use the

if(isset($_GET['flag'])){
  if($_GET['flag']== 'a'){
   //Update with accept
  }
  elseif($_GET['flag']=='d'{
   //update with decline
  }
  else{
   echo "stop messing about with the address bar!";
  }
}

Link to comment
https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329133
Share on other sites

hey thanks for the explination im trying to do the following

:

if(isset($_GET['flag'])){

  if($_GET['flag']== 'a'){

  mysql_query("UPDATE bids SET Firm_ID = '$firmid', DeclienedByCustomer= '0' WHERE Quote_ID=$qid") or die (mysql_error());

  mysql_query("UPDATE quotes SET Firm_ID = '$firmid', accept_Decline= '1' WHERE Quote_ID=$qid") or die (mysql_error());

  }

  else($_GET['flag']=='d'{

  mysql_query("UPDATE bids SET Firm_ID = '$firmid', DeclienedByCustomer= '1' WHERE Quote_ID=$qid") or die (mysql_error());

  mysql_query("UPDATE quotes SET Firm_ID = '$firmid', accept_Decline= '0' WHERE Quote_ID=$qid") or die (mysql_error());

  }

  else{

  echo "stop messing about with the address bar!";

  }

}

 

  } // close while

 

as its in a while loop and i need to update it in 2 different tables but it is saying

 

Parse error: parse error, unexpected '{' in E:\students\08023190\taxi\TaxiEntry.php on line 55

any ideas ?

 

 

Link to comment
https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329163
Share on other sites

as I have no idea which line is 55, or what loop your talking about I can't be sure, but I suspect it's because you can only have one else for each if, you can however have as many elseif{}'s as you like.  Also, you can UPDATE 2 tables using a single statement, look into UPDATE with JOIN.

Link to comment
https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329335
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.