spearchilduser Posted March 19, 2012 Share Posted March 19, 2012 hi how do u do a if statement so that if <a href="TaxiEntry1.php?Quote_ID='.$qid.'">Accept</a> is clicked then update this field in this table } thanks Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/ Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 need a little more info regarding your current page logic to be certain, but something like this: if(isset($_GET['Quote_id'])){ //update database } Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329122 Share on other sites More sharing options...
spearchilduser Posted March 19, 2012 Author Share Posted March 19, 2012 $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 Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329124 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 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!"; } } Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329133 Share on other sites More sharing options...
spearchilduser Posted March 19, 2012 Author Share Posted March 19, 2012 ok i undertsand the principle but im relatively newish and what is a flag ? Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329136 Share on other sites More sharing options...
Muddy_Funster Posted March 19, 2012 Share Posted March 19, 2012 a flag is just a term, don't worry about it, just alter your links to be like: <td><a href="TaxiEntry1.php?Quote_ID='.$qid.'&flag=a">Accept</a> <a href="decline.php?Quote_ID='.$qid.'&flag=d">Decline</a></td> Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329138 Share on other sites More sharing options...
spearchilduser Posted March 19, 2012 Author Share Posted March 19, 2012 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329163 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329335 Share on other sites More sharing options...
spearchilduser Posted March 20, 2012 Author Share Posted March 20, 2012 Ok thank you its all resolved now Thanx so much Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329439 Share on other sites More sharing options...
Muddy_Funster Posted March 20, 2012 Share Posted March 20, 2012 no problem, glad you got it all worked out. good luck. Quote Link to comment https://forums.phpfreaks.com/topic/259271-if-statement/#findComment-1329442 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.