update table on page entry
hi,
What is the best way to update a table on page entry?
I have a record I need to add a value of 1 to once it is loaded (this is not a counter)
By default the value is 0 added by mysql. I want to update it for when the user has viewed that record when the message.php page is loaded for the id of that page.
I have done this so far, but I want to submit it without having a button on the page.
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "update_message_status")) {
$updateSQL = sprintf("UPDATE mailbox SET viewed=%s WHERE mailbox_id=%s",
GetSQLValueString($_POST['viewed'], "text"),
GetSQLValueString($_POST['mailbox_id'], "int"));
mysql_select_db($database_db, $db);
$Result1 = mysql_query($updateSQL, $db) or die(mysql_error());
$updateGoTo = "message.php?id='".$row_messagesList['mailbox_id']."'";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
<form action="<?php echo $editFormAction; ?>" method="POST" name="update_message_status">
<input name="mailbox_id" type="hidden" value="<?php echo $row_messagesList['mailbox_id']; ?>" />
<input name="viewed" type="hidden" value="1" />
<input type="hidden" name="MM_update" value="update_message_status" />
</form>
Thanks
