CurrierSites Posted January 21, 2008 Share Posted January 21, 2008 I have a query page which displays the contents of a table name, age, sport --------------------- bob, 30, baseball jim, 34, football steve, 23, hockey I want to be able to edit these entries by passing the name of an individual to a new page where where I can edit that individuals information. My goal is to pass the name of one person as a variable that will be used by the next page to query the DB and display the fields to be edited. Im not quite sure to get that variable passed to the next page so it can be used in query (i.e. select * from DATABASE where name='PASSED VARIABLE' I would appreciate any suggestions on this problem. Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/ Share on other sites More sharing options...
revraz Posted January 21, 2008 Share Posted January 21, 2008 You can use $_GET or a Session Variable. I would use sessions myself. Also, having a ID for the record would make it a little easier and a bit safer. Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/#findComment-445247 Share on other sites More sharing options...
pocobueno1388 Posted January 21, 2008 Share Posted January 21, 2008 You can do it through the URL using GET. So your URL to the page should look something like this www.yourdomain.com/page.php?name=steve Then on that page, you could retrieve the information and do your query like so <?php $name = mysql_real_escape_string($_GET['name']); $query = "SELECT* FROM table WHERE name='$name'"; ?> Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/#findComment-445248 Share on other sites More sharing options...
CurrierSites Posted January 21, 2008 Author Share Posted January 21, 2008 how do I create the url out of the preceding page? Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/#findComment-445254 Share on other sites More sharing options...
revraz Posted January 21, 2008 Share Posted January 21, 2008 On the name, just create a link that has the name variable included in it. Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/#findComment-445262 Share on other sites More sharing options...
adam291086 Posted January 21, 2008 Share Posted January 21, 2008 somthing like <ahref ="http://yourdomain.co.uk/page.php?<?php echo $name ?>"><?php echo $name?></a> Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/#findComment-445264 Share on other sites More sharing options...
CurrierSites Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks for everyone's help. Im all set. Link to comment https://forums.phpfreaks.com/topic/87062-solved-pass-variable-to-page-prior-to-populating-data-from-the-db/#findComment-445277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.