I am displaying a MySQL database on webpage (php) for live updating. I am brand new to AJAX and cannot get the page to update the database. Thank you so much for the help. Here is the javascript and AJAX code:
if(send == "send")
{
$.ajax({
type: "POST",
url: "table_edit_ajax.php",
data: dataString,
cache: false,
success: function(html)
{
$("#Receiving_" + ID).html(Receiving);
$("#Rreg_" + ID).html(Rreg);
$("#Sending_" + ID).html(Sending);
$("#Sreg_" + ID).html(Sreg);
$("#Name_" + ID).html(Name);
$("#Received_" + ID).html(Received);
$("#ToRC_" + ID).html(ToRC);
$("#Approved_" + ID).html(Approved);
$("#Denied_" + ID).html(Denied);
$("#Notes_" + ID).html(Notes);
$("#Status_" + ID).html(Status);
$("#Send_" + ID).html(Send);
$("#Notified_" + ID).html(Notified);
}
});
}
else
{
$.ajax({
type: "POST",
url: "table_edit.php",
data: dataString,
cache: false,
success: function(html)
{
$("#Receiving_" + ID).html(Receiving);
$("#Rreg_" + ID).html(Rreg);
$("#Sending_" + ID).html(Sending);
$("#Sreg_" + ID).html(Sreg);
$("#Name_" + ID).html(Name);
$("#Received_" + ID).html(Received);
$("#ToRC_" + ID).html(ToRC);
$("#Approved_" + ID).html(Approved);
$("#Denied_" + ID).html(Denied);
$("#Notes_" + ID).html(Notes);
$("#Status_" + ID).html(Status);
$("#Send_" + ID).html(Send);
$("#Notified_" + ID).html(Notified);
}
});
}
});
And here is the PHP code to update the database after connecting:
$id=mysql_escape_String($_POST['id']);
$Receiving=mysql_escape_String($_POST['Receiving']);
$Rreg=mysql_escape_String($_POST['Rreg']);
$Sending=mysql_escape_String($_POST['Sending']);
$Sreg=mysql_escape_String($_POST['Sreg']);
$Name=mysql_escape_String($_POST['Name']);
$Received=mysql_escape_String($_POST['Received']);
$ToRC=mysql_escape_String($_POST['ToRC']);
$Approved=mysql_escape_String($_POST['Approved']);
$Denied=mysql_escape_String($_POST['Denied']);
$Notes=mysql_escape_String($_POST['Notes']);
$Status=mysql_escape_String($_POST['Status']);
$Send=mysql_escape_String($_POST['Send']);
$Notified=mysql_escape_String($_POST['Notified']);
$sql = "update transfers set
Receiving='$Receiving',
Rreg='$Rreg',
Sending='$Sending',
Sreg='$Sreg',
Name='$Name',
Received='$Received',
ToRC='$ToRC',
Approved='$Approved',
Denied='$Denied',
Notes='$Notes',
Status='$Status',
Send='$Send',
Notified='$Notified'
where id='$id'";
mysql_query($sql);
?>
Thanks again for the help. If needed I will post the body of the main document to edit the table.