Passing details to another page
Posted 14 July 2006 - 01:35 PM
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?
Posted 14 July 2006 - 01:42 PM
$query = "select * from suppliers where id='$id'";
maybe you should clarify your question with more details.
Posted 14 July 2006 - 01:52 PM
Does that help?
Posted 14 July 2006 - 02:06 PM
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.
Posted 14 July 2006 - 02:07 PM
<?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>'; ?>
I use the function mysql_real_escape_string() to prevent sql injections.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users