I have a simple form which updates values in the db via ajax call to another page and returns success message and loads values. Each page determines which record to update via querystring (ie index.php?clientid=2).
For some reason, when my ajax call returns and reloads, it is losing the querystring value and getting set to default, clearing it so that the following php part of the code no longer gets it:
<?php if(isset($_GET["clientid"])) {
$clientidstring = $_GET["clientid"];
} else {
$clientidstring = 1;
}
$sql = mysql_query("select * from profiles where id=" . $clientidstring);
$row = mysql_fetch_array($sql); ?>
So what happens on update is that clientid “1” is always being returned instead of current url querystring value for it (which still shows in the URL field in the browser btw).
DB is updating fine, and with the correct record. And if I reload the page entirely, it will show the correct values. The only problem seems to be the ajax callback clearing the url parameter that is used in the db call.
Ok, I figured this out. For anyone who this may help, it turned out that when reloading my changes, I needed to pass the querystring in the partial jQuery.load, so this:
gets changed to this:
And now, all is well. Thanks to anyone that read this and tried to help, I probably was not as clear as I should have been.