Jump to content

Recommended Posts

I'm sure this is really simple and I'm just missing something. I've got a recordset returned via mySQLi, and I want to take the unique ID from that record and add it into to a URL as such: 

href="details.php?UID= <insert the unique ID from the record here>";  .. but I just can't seem to wrap my head around how to do it.  Thoughts are welcome.

Link to comment
https://forums.phpfreaks.com/topic/295301-adding-a-variable-to-a-referring-url/
Share on other sites

Sorry, let me clarify a bit.. this is after an UPDATE is done, and we're referring to a new page.. it's not a link.  So here's a better demonstration of the context:

 

$UpdateGoTo = "show.php?GuestID=<something goes here>";  

 

Or maybe its 

 

$UpdateGoTo = "show.php?GuestID="<something goes here>;

 

This is where my ignorance is showing.. thx

$UpdateGoTo = "show.php?GuestID=".$whateverTheIDIs;
It's up to you and your code to define $whateverTheIDIs. There's no "just do this, it'll work" answer. You just have to get the ID from somewhere, append it to your URL using concatenation, then redirect to that URL using header.

Yes, I've done this, and when echo'd, I can see the value is properly assigned. Somehow however, on show.php, the GuestID value is lost. It doesn't populate over into the referring URL for some reason. Is this a mySQLi thing??  This method works fine in usual PHP/mySQL methods.

Wait, now it sounds like the problem isn't in the code that writes the ID into the header location string, but in the receiving page?

 

Show us the code you're working on. Without seeing the code that's not working and having a detailed and complete description of what 'working' means in the context of the code and project, folks here are stabbing blindly in the dark and can't help, even though they may want to.

Edited by maxxd

Here is the update/redirect that's supposed to be passing the variable:

if (isset($_POST["CreateButton"]) || isset($_POST["CreateButton_x"])) {
  $UpdateQuery = new WA_MySQLi_Query($SI);
  $UpdateQuery->Action = "update";
  $UpdateQuery->Table = "SomeTable";
  $UpdateQuery->bindColumn("LastName", "s", "".((isset($_POST["LastName"]))?$_POST["LastName"]:"")  ."", "WA_DEFAULT");
  $UpdateQuery->addFilter("GuestID", "=", "i", "".((isset($_POST["GuestID"]))?$_POST["GuestID"]:"")  ."");
  $UpdateQuery->execute();
  $UpdateGoTo = "show.php?GuestID=".$GuestID;
  if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
  $UpdateQuery->redirect($UpdateGoTo);
}
 
 
and here is the code to pull the recordset based on the GuestID that we're trying to append in the URL:
 
$Recordset1 = new WA_MySQLi_RS("Recordset",$SI,1);
$Recordset1->setQuery("SELECT * FROM SomeTable WHERE GuestID = ?");
$Recordset1->bindParam("i", "".(isset($_GET['GuestID'])?$_GET['GuestID']:"")  ."", "-1"); //colname
$Recordset1->execute();
Edited by adrianle
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.