Jump to content

Passing details to another page


genista

Recommended Posts

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?


Thanks

G
Link to comment
https://forums.phpfreaks.com/topic/14582-passing-details-to-another-page/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.