Jump to content


Photo

Update Record -> Return Old Info


  • Please log in to reply
3 replies to this topic

#1 dtyson2000

dtyson2000
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 21 July 2006 - 01:43 AM

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.

#2 treilad

treilad
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts

Posted 21 July 2006 - 01:49 AM

You need to post your code.  ::)

#3 dtyson2000

dtyson2000
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 21 July 2006 - 02:10 AM

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?

#4 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 21 July 2006 - 06:22 AM

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

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();
}

at the top of the whole script.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users