Hi:
I'm not sure that this problem has a solution but here goes. I am retrieving a list of names from a database and displaying them on a web page. The list would have the form:
Doe, John
Smith, Harry
Jones, Dan

I want each name to be a hyperlink and when clicked, it would call a php page sending it the clicked upon name, e.g Doe, John. How do I send that information to the called page using a hyperlink? Is there a superior solution to this problem?

Sheridan :(

Query strings are used when you need to send data through the URL.

<a href="somePage.php?first_name=Foo&last_name=Barr">Barr, Foo</a>

When a user clicks on that link it will send them to the page somePage.php with the following data.

first_name = Foo
last_name = Barr

The first variable is appended to the url with ?<variable name>=<value>. Any additional variables are appended with an ampersand, ie., somePage.php?var1=blah&var2=blah2 Hope that helps.

Hi:
Solution looks good. Will try soonest.:)

Oh, You can access the values as $value = $_GET['variablename'] Don't forget to sanitize the user's input by using mysql_real_escape_string or addslashes.

Hi:
I'm not sure that this problem has a solution but here goes. I am retrieving a list of names from a database and displaying them on a web page. The list would have the form:
Doe, John
Smith, Harry
Jones, Dan

I want each name to be a hyperlink and when clicked, it would call a php page sending it the clicked upon name, e.g Doe, John. How do I send that information to the called page using a hyperlink? Is there a superior solution to this problem?

Sheridan :(

why do you want to send first and last name over URL? instead, you can send userId (something like:
<a href="./somepage.php?uId=<?php echo $userId ?>"><?php echo $userName ?></a>).
And on somepage.php you'll perform a database request to get what infos you want about that user. what will you do if you want to display his age? you'll send it over URL too?

Best regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.