Jump to content

Two actions on one button


Shamrox

Recommended Posts

I'm trying to improve the interactivity of a table of data. Currently, I have a column that displays an image and when clicked it takes the users to a form for emailing a reminder. Right next to that is a button that clears that record from the table when that reminder has been emailed.

I'd like to make it so that the user only has to click on the first button/image and as it takes them to the email form page, it also updates the record in the database and would clear it from the table based on the status field being set to Yes.

 

Currently here is my code, but it's not updating the database status field at all.

 

Here is the code for the two columns.

 <td align="center" class="tabletext"><a href="email_form.php?form=reminderconfirmation&registrarid=<?php echo $row_rs_reminder['registrarid']; ?>"><img src="images/icon_reminder.jpg" alt="Reminder Agreement" width="18" height="20" border="0" align="center"></a>
            <div align="center"></div></td>
          <td align="center" class="tabletext">
            <form id="clear" name="clear" method="post" action="<?php echo $editFormAction; ?>">
            <button type="submit"><img src="/mdwapp/images/0090_check.gif" alt="Check" width="12" height="12" border="0"></button><input name="registrarid" type="hidden" value="<?php echo $row_rs_reminder['registrarid']; ?>" /><input name="clearstatus" type="hidden" value="Yes" />
            </form>
	  </td>

 

Here is my code for submitting to database, but this doesn't do anything and not sure why.

<?php
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "clear")) {
  $updateSQL = sprintf("UPDATE spec_registrar SET clearstatus=%s WHERE registrarid=%s",
                       GetSQLValueString($_POST['clearstatus'], "text"),
                       GetSQLValueString($_POST['registrarid'], "int"));

  mysql_select_db($database_spectrum, $spectrum);
  $Result1 = mysql_query($updateSQL, $spectrum) or die(mysql_error());

  $updateGoTo = "dashboard.php?page=reminder";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
?>

 

Can someone tell me how I'd put the two functions together and get it to update the status? Thanks.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.