Jump to content

Archived

This topic is now archived and is closed to further replies.

dtyson2000

Update Record -> Return Old Info

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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.