genista Posted July 14, 2006 Share Posted July 14, 2006 Hi all,I have a search form that a user submits. The results come back with the ability to click on them and look at the search result details in a supplierdetails.php page.I have the following query to match the page to the search results, but am having problems deciding how to use the query to display the details of the supplier. The query goes like such:$id = $_GET['id'];$query = "select * from suppliers where id=$username";Has anybody got any examples I could look at to get an idea?ThanksG Quote Link to comment https://forums.phpfreaks.com/topic/14582-passing-details-to-another-page/ Share on other sites More sharing options...
hvle Posted July 14, 2006 Share Posted July 14, 2006 $id = $_GET['id'];$query = "select * from suppliers where id='$id'";maybe you should clarify your question with more details. Quote Link to comment https://forums.phpfreaks.com/topic/14582-passing-details-to-another-page/#findComment-57891 Share on other sites More sharing options...
genista Posted July 14, 2006 Author Share Posted July 14, 2006 Ok well the id will be supplierid as this is called from the suppliers table. The problem as you well know is that the query won't display anything, but I am interested in knowing they wain which to display the details of the supplier on the page.Does that help? Quote Link to comment https://forums.phpfreaks.com/topic/14582-passing-details-to-another-page/#findComment-57898 Share on other sites More sharing options...
hvle Posted July 14, 2006 Share Posted July 14, 2006 so you got the query set up.you'll need to connect to mysql server, select database, execute the query, retrieve results and display the data.Refer to mysql function reference in PHP manuals, it has everything you needed. Quote Link to comment https://forums.phpfreaks.com/topic/14582-passing-details-to-another-page/#findComment-57910 Share on other sites More sharing options...
kenrbnsn Posted July 14, 2006 Share Posted July 14, 2006 After you do the query, you have to use one of the mysql_fetch functions to actually get the data so you can display it. In it's simplest form this would be:[code]<?php$id = $_GET['id'];$query = "select * from suppliers where id='" . mysql_real_escape_string($id) . "'";$rs = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());while ($rw = mysql_fetch_assoc($rs)) echo '<pre>' . print_r($rw,true) . '</pre>';?>[/code]I use the function mysql_real_escape_string() to prevent sql injections.Ken Quote Link to comment https://forums.phpfreaks.com/topic/14582-passing-details-to-another-page/#findComment-57912 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.