Jump to content

Update Record -> Return Old Info


dtyson2000

Recommended Posts

Hi again guys.

I've really been picking up a lot here. For that, I thank you! So moving along in my learning:

I've made a basic system of inputting data into a database, searching that information and editing/updating that information a record at a time, where there's a need.

Everything is working better than I could ever have imagined EXCEPT:

When I pull a record to be updated/edited and input the changes, hit submit, the page returns me to the old data. The database is changed and I can see the changes in my search results. I guess I'm wondering if there's some sort of small command I may be missing that would reload the edit/update page with the new content.

What do you think?

Again, thank you for all of your help!

Edit: It's probably something really basic. Sorry.
Link to comment
Share on other sites

Here's the part that's processing the update:

if ($ud_update){
global $id;
include('db_connect.inc');
$query = "UPDATE inventory SET ***variables here, it's long*** WHERE id='$id'";
mysql_query($query);
echo "Record Updated";
mysql_close();
}

Hope that's enough?
Link to comment
Share on other sites

Try putting the part that is processing the update at the very top of your script. That will tell your computer to:

1. first update the information.
2. THEN display it to the screen.

Instead of:

1. First display information to the screen.
2. Then update all the information.

Hopefully this makes sense.

So just put

[code]if ($ud_update){
global $id;
include('db_connect.inc');
$query = "UPDATE inventory SET ***variables here, it's long*** WHERE id='$id'";
mysql_query($query);
echo "Record Updated";
mysql_close();
}[/code]

at the top of the whole script.
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.