BadGoat Posted June 24, 2006 Share Posted June 24, 2006 Hello!I wrote a script which enters a few variables into a database. I wanted to be able to click a link to add further details to the database. The plan was to have this on the page which echoes the variables just added to the db. (details which are not necessary, hence a different page to enter them on should the user want to add the further information) I am not certain how to create a link which will put the id into the link, so that on the resultant page I can add further info based on the ID. If someone could punt me in the right direction, I would be most appreciative (and my headache would go away)Here's a snippet of some of the code I have. The link at the bottom doesn't add the ID, although I can echo it using the mysql_insert_id at the beginning:<tr> <td> ID:</td> <td>'; echo mysql_insert_id(); echo'</td></tr><tr> <td>First Name:</td> <td>' .$fn. '</td></tr><tr> <td>Middle Namee:</td> <td>' .$mn. '</td></tr><tr> <td class="header3">Last Name:</td> <td>' .$ln. '</td></tr><tr> <td class="header3">Birthday:</td> <td>' .$bd. '</td></tr><tr> <td>Add More Detail</td></tr><tr> <td><a href="add_detail.php?id='.$id.'">Add Details</a></td></tr> Quote Link to comment https://forums.phpfreaks.com/topic/12825-unsure-how-to-pass-id-field-in-a-link/ Share on other sites More sharing options...
ale_jrb Posted June 24, 2006 Share Posted June 24, 2006 To get the ID, set it to a variable like so:[code]$id = mysql_insert_id()[/code]Put the above variable as your link (/add_detail.php?id='.$id.').Then on your add_detail.php page, you have to use the $_GET command.For example:[code]if(isset($_GET['id'])){$id = $_GET['id'];$moreinfo = "true";}if($moreinfo = "true"){Type code that you want to happen if the link is clicked here...}else{Type code you want to happen if the page is accessed by typing "www.yoururl.com/add_detail.php" in the browser by itself.}[/code]Does this help you? Your question is quite unclear. Quote Link to comment https://forums.phpfreaks.com/topic/12825-unsure-how-to-pass-id-field-in-a-link/#findComment-49187 Share on other sites More sharing options...
BadGoat Posted June 24, 2006 Author Share Posted June 24, 2006 Thank you ale, that makes perfect sense. Pardon my unclear question, it makes perfect sense in my head, but when trying to express it in a question gets muddled .. Due to being a nooblet. I understand your reply, and I will implement!Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/12825-unsure-how-to-pass-id-field-in-a-link/#findComment-49195 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.