braden Posted March 13, 2008 Share Posted March 13, 2008 I wanted to know how to post the mysql record "id" in the url (ie http://mysite.com/searchresult.php?id=326) after a search. Is there a particular function that would let me echo that variable in the url after a search? This way I can use "get" for navigation. Regards, Bradem Link to comment https://forums.phpfreaks.com/topic/95950-returning-url-with-mysql-record-id-after-search/ Share on other sites More sharing options...
atticus Posted March 13, 2008 Share Posted March 13, 2008 Bradem, please give more details about the search. Do you want the pages found in the search to have the link id, or the actual search results page. Link to comment https://forums.phpfreaks.com/topic/95950-returning-url-with-mysql-record-id-after-search/#findComment-491203 Share on other sites More sharing options...
soycharliente Posted March 13, 2008 Share Posted March 13, 2008 <?php $id = $_GET['id']; $sql = "SELECT * FROM `table` WHERE `id`='$id'"; $result = mysql_query($sql) OR DIE("$sql :: ".mysql_error()); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { // do something } } else { // do something else } ?> Link to comment https://forums.phpfreaks.com/topic/95950-returning-url-with-mysql-record-id-after-search/#findComment-491207 Share on other sites More sharing options...
soycharliente Posted March 13, 2008 Share Posted March 13, 2008 Also you want to remember that with using $_GET comes some security issues. So Google for $_GET and security to see what some of the best practices are when using it. Link to comment https://forums.phpfreaks.com/topic/95950-returning-url-with-mysql-record-id-after-search/#findComment-491210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.