Closed Thread Icon

Topic awaiting preservation: PHP: querying mySQL db (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12374" title="Pages that link to Topic awaiting preservation: PHP: querying mySQL db (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP: querying mySQL db <span class="small">(Page 1 of 1)</span>\

 
Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 08-20-2002 21:08

I have an HTML page with a table containing two columns and about 12 rows of names, each name represents a query to the database for the records of that persons name. I have the query working on a stand alone page but I'm unsure how to make the links for each person's name query each person's unique set of records.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 08-20-2002 22:09

You mean you want to have the name link to another page which will display the person's info?

Usually what you do is link to something like a generic info page and pass it a persons name(or id) in the QueryString something like
a href="info_page.php?name=John+Smith" (if you are passing a name make sure to urlencode it to get rid of spaces.

As a rule
(and you may be doing this but just not mentioning it) when you create a table like this you should have one unique/auto_increment row that will create unique ID's for each user since theoretically a name could be used more than once. This also makes querying easier since you don't have to worry about spaces, caps etc. So you could pass the unique ID instead.



.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 08-20-2002).]

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 08-20-2002 22:10

well you would usually have that name as link inside a form that would send that name in either a POST or a GET method to either another php page or the same one depending on how you want it to react.

So then your php would check $_POST["name"] or $_GET["name"] for the name that was sent as the value of name and retrieve the corresponding results from the DB for that name.

If you were not aware of $_POST and $_GET, they are superglobals put in after php version 4.1.0.
All required reading is at php.net somewhere.


edit: bit beat me by a minute! must.type.faster.

[This message has been edited by genis (edited 08-20-2002).]

Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 08-21-2002 03:41

Thank you very much I think that's exactly what I was looking for...

« BackwardsOnwards »

Show Forum Drop Down Menu