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
Share on other sites

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?
Link to comment
Share on other sites

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.
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.