Jump to content

Recommended Posts

I'm very new to MySQL and trying to learn the basics.

 

My question is this:

 

I've created a simple database containing details of items owed to various patients by the pharmacy. I have made a search feature so that the staff can search quickly. In the search results, each patient's name is hyperlinked. When the hyperlink is clicked, I want it to go to a page where it displays all data from that row in the database table related to that patient.

 

I have done this with an OwingID auto-incrementing variable in the table.

 

I have the page set up where the data will display and can make it display any record I choose with this command:

 

$displayowing = mysql_query("SELECT Date, FirstName, LastName, Item, Quantity FROM tOwings WHERE OwingID=1");

 

but I have to change the OwingID in the code myself from the server side.

 

How do I make the links from the search results do this for me?

 

Thanks...

Add the id to the link with a querystring

 

<a href='mypage.php?id=42'>name</a>

 

in the php script:

 

$id = intval($_GET['id']);
$displayowing = mysql_query("SELECT Date, FirstName, LastName, Item, Quantity FROM tOwings WHERE OwingID=$id ");

Edited by Barand
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.