Jump to content

[SOLVED] Help creating a conditional update query


czs

Recommended Posts

Right now I have these two working update queries that dreamweaver made for me:

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE tblprofile SET Match1=%s WHERE email=%s",
                       GetSQLValueString($_POST['M1Accept'], "text"),
                       GetSQLValueString($_POST['M1email'], "text"));
				   
  mysql_select_db($database_connPFD, $connPFD);
  $Result1 = mysql_query($updateSQL, $connPFD) or die(mysql_error());
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE tblprofile SET ConMatch1=%s WHERE email=%s",
                       GetSQLValueString($_POST['M1email'], "text"),
                       GetSQLValueString($_POST['HFEmail'], "text"));

  mysql_select_db($database_connPFD, $connPFD);
  $Result1 = mysql_query($updateSQL, $connPFD) or die(mysql_error());
}

 

The first one inputs the value from a radio group named M1accept into the database.  M1accept is a radio group that either submits this if true: <?php echo $_SESSION['MM_Username']; ?>  and just a 0 if false.

 

Here is the thing.  I only want the second update listed above to run only if the user clicked the true value for M1accept radio group.  So if <?php echo $_SESSION['MM_Username']; ?> gets sent in then I want the second query to run but if "0" gets submitted then I don't want the second query listed above to run. 

 

Is there to put some sort of if statement around the second update that I have?  Any other way to do this?

 

Thank you very much

Thank you so much! 

 

Your exact code didn't work but it inspired me to create the code that did work.  This is awesome.

 

Instead of

 

if ($_POST['M1Accept'] == 1

 

I just put

 

if ($_POST['M1Accept'] == $_SESSION['MM_Username']

 

Which is the value that M1accept submits if true.  Thanks!

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.