Jump to content

Parse recordID after UPDATE


yandoo

Recommended Posts

Hi there,

 

I have a form that updates a record in a database...At the moment on Update the user is directed to another page....

 

Is there a way i can parse the ID value that was just updated to the other page (like a hyperlink, e.g. ?recordID=<?php echo $row_record['ID']; ?>)......Because i need to parse the ID to the other page!

 

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE animal SET BreedID=%s, Age=%s, Sex=%s, Image=%s WHERE AnimalID=%s",
                       GetSQLValueString($_POST['select'], "text"),
                       GetSQLValueString($_POST['age'], "int"),
                       GetSQLValueString($_POST['sex'], "text"),
             
                       GetSQLValueString($_POST['image'], "text"),
                       GetSQLValueString($_POST['AnimalID'], "int"));

  mysql_select_db($database_woodside, $woodside);
  $Result1 = mysql_query($updateSQL, $woodside) or die(mysql_error());

  $updateGoTo = "view_animal_details.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));

 

What i have done so far is add the following code:

 

 $updateGoTo .= '&' . $_POST['AnimalID'];
   }else{
    $updateGoTo .= '?' . $_POST['AnimalID'];
  } 

 

Its almost working but not quite.... The address bit in browser says: http://localhost/woodside/view_animal_details.php?&55

 

So the record number 55 looks like it is being parsed, but records are dislpayed on that page!???

normally when i parse a hyperlink parameter the browser says view_animal_details.php?recordID=53

 

The browser addresss should be saying: http://localhost/woodside/view_animal_details.php?recordID=55

 

I know its close to working, but just out of reach...

 

Would could i to get it to parse properly??

 

Thanks  :)

Link to comment
https://forums.phpfreaks.com/topic/98612-parse-recordid-after-update/
Share on other sites

Archived

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

×
×
  • 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.