Reputation: 988
http://imageshack.us/photo/my-images/221/mysystem.jpg/
Anyone can help me, I stuck right now at first column, which is Total Pending Column, I cannot change the data of "200" at frontend page, I just can edit it manually at backend page which is at phpmyadmin, it's difficult to my user to change the data at the front side, BUT it make me confused why the other column can be able to edit at the front? Just only the Total Pending column cannot be edit, when I click update button, the others updated except first column.
Please help me..
Herewith my Update PHP Coding
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE sr1 SET appt_today=%s, partial_complete=%s, full_complete=%s, return_technical=%s, return_customer=%s, return_cancel=%s, cancel=%s, reappt=%s, focus=%s WHERE total_pending=%s",
GetSQLValueString($_POST['appt_today'], "int"),
GetSQLValueString($_POST['partial_complete'], "int"),
GetSQLValueString($_POST['full_complete'], "int"),
GetSQLValueString($_POST['return_technical'], "int"),
GetSQLValueString($_POST['return_customer'], "int"),
GetSQLValueString($_POST['return_cancel'], "int"),
GetSQLValueString($_POST['cancel'], "int"),
GetSQLValueString($_POST['reappt'], "int"),
GetSQLValueString($_POST['focus'], "int"),
GetSQLValueString($_POST['total_pending'], "int"));
mysql_select_db($database_pods, $pods);
$Result1 = mysql_query($updateSQL, $pods) or die(mysql_error());
$updateGoTo = "main.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_pods, $pods);
$query_sr1 = "SELECT * FROM sr1";
$sr1 = mysql_query($query_sr1, $pods) or die(mysql_error());
$row_sr1 = mysql_fetch_assoc($sr1);
$totalRows_sr1 = mysql_num_rows($sr1);
?>
And Here is my Coding for input data, which I state above is "200" but cannot be update.
<input name="total_pending" type="text" class="style6" onKeyPress="return checkIt(event)" value="<?php echo $row_sr1['total_pending']; ?>" size="3" maxlength="3" />
Upvotes: 0
Views: 137
Reputation: 218857
Your SQL query doesn't update any value called total_pending
:
UPDATE
sr1
SET
appt_today=%s,
partial_complete=%s,
full_complete=%s,
return_technical=%s,
return_customer=%s,
return_cancel=%s,
cancel=%s,
reappt=%s,
focus=%s
WHERE
total_pending=%s
You use total_pending
to find the record(s) you want to update, but you don't actually update that value in that/those record(s).
Keep in mind that in order to update the same field you're using to find the record(s), you'll need to include that parameter twice with two different values. One for the new value to which it should update and one for the existing value which it uses to find the record(s).
For example:
UPDATE
sr1
SET
appt_today=%s,
partial_complete=%s,
full_complete=%s,
return_technical=%s,
return_customer=%s,
return_cancel=%s,
cancel=%s,
reappt=%s,
focus=%s,
total_pending=%s -- update this field as well
WHERE
total_pending=%s
Edit: To clarify a bit more for you, the first thing you'll want to do is add another field to the form to track a separate total_pending
value. This is because you'll need two of them for the update, one representing the original value (for the WHERE
clause) and one representing the new value. So you'll want to add something like this:
<input name="total_pending_original" type="hidden" value="<?php echo $row_sr1['total_pending']; ?>" />
Then, using the updated query I gave you above, you'll also need to add a new parameter. So the total query/parameter code should look like this:
$updateSQL = sprintf("UPDATE sr1 SET appt_today=%s, partial_complete=%s, full_complete=%s, return_technical=%s, return_customer=%s, return_cancel=%s, cancel=%s, reappt=%s, focus=%s, total_pending=%s WHERE total_pending=%s",
GetSQLValueString($_POST['appt_today'], "int"),
GetSQLValueString($_POST['partial_complete'], "int"),
GetSQLValueString($_POST['full_complete'], "int"),
GetSQLValueString($_POST['return_technical'], "int"),
GetSQLValueString($_POST['return_customer'], "int"),
GetSQLValueString($_POST['return_cancel'], "int"),
GetSQLValueString($_POST['cancel'], "int"),
GetSQLValueString($_POST['reappt'], "int"),
GetSQLValueString($_POST['focus'], "int"),
GetSQLValueString($_POST['total_pending'], "int"),
GetSQLValueString($_POST['total_pending_original'], "int"));
Also, one thing you should note is that you should not being mysql_* functions anymore. PHP is deprecating them. Take a look at the big red box indicating that here.
Upvotes: 1