Jump to content

Very Simple Question About Displaying Mysql Database Data


JakeMogul

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 ");

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.