adrianle Posted March 16, 2015 Share Posted March 16, 2015 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. Quote Link to comment Share on other sites More sharing options...
tryingtolearn Posted March 17, 2015 Share Posted March 17, 2015 Depending on how you are getting your data from the DB here is one way if the row is called UID echo'<a href="detils.php?UID='.$row['UID'].'">Link Text</a>'; Quote Link to comment Share on other sites More sharing options...
adrianle Posted March 17, 2015 Author Share Posted March 17, 2015 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 Quote Link to comment Share on other sites More sharing options...
kicken Posted March 17, 2015 Share Posted March 17, 2015 $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. Quote Link to comment Share on other sites More sharing options...
adrianle Posted March 17, 2015 Author Share Posted March 17, 2015 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. Quote Link to comment Share on other sites More sharing options...
maxxd Posted March 17, 2015 Share Posted March 17, 2015 (edited) 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 March 17, 2015 by maxxd Quote Link to comment Share on other sites More sharing options...
adrianle Posted March 17, 2015 Author Share Posted March 17, 2015 (edited) 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 March 17, 2015 by adrianle Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.