Page 1 of 4

Simple php link code

Posted: Sat Jun 07, 2003 11:09 am
by I3lade
Ok i gotta make my link like

Code: Select all

<a href="page.php?varibale=value">here</a>
but don't know what exactly to put in variable=value. Im a newbi so id appercaite your help.

Posted: Sat Jun 07, 2003 11:17 am
by I3lade
Anyone please?

Posted: Sat Jun 07, 2003 11:17 am
by twigletmac
What information are you trying to pass in the link? The values for 'variable' and 'value' are going to be different depending on what you need to pass from one page and what needs to be received by the next page.

Mac

Posted: Sat Jun 07, 2003 11:19 am
by I3lade
Its a profile code, like i want when they click it it shows that user profile. Example: They click user bob, it opens a page and shows bobs info.

Posted: Sat Jun 07, 2003 11:26 am
by redhair
the profiles are in a mysql db?

Posted: Sat Jun 07, 2003 11:27 am
by I3lade
Yea.... but what do i put in my link code?

Posted: Sat Jun 07, 2003 11:31 am
by twigletmac
Well what does the script look like that's supposed to handle the next part when a person clicks on a link? The link itself is nothing special, just a way of passing information to the script that does the actual work.

Mac

Posted: Sat Jun 07, 2003 11:32 am
by I3lade
Its a Select code to select what they inserted into the datbase

Posted: Sat Jun 07, 2003 11:33 am
by twigletmac
Well you must have something in that code which needs to be set in order to uniquely identify that person - so pass that in the link.

Mac

Posted: Sat Jun 07, 2003 11:34 am
by I3lade
yea a "id" thats the name of the feild, what would the lihnk look like?

Posted: Sat Jun 07, 2003 11:37 am
by I3lade
like ummm

Code: Select all

<a href="page.php?username=id">here</a>

or something?

Posted: Sat Jun 07, 2003 11:39 am
by redhair
The row_id of the user requested from the database?

Supposed you have these fields in your table
user_id, fname, lname

To get a certain user from the db, you could try:

user.php

Code: Select all

<?php
if (isset($_get['user_id']))


{$mysqlquery = "SELECT * FROM user_table WHERE user_id = "$user_id"";

		$result = MYSQL_QUERY($query);

		while ($row = mysql_fetch_array($result)) {

		$fname = $row['fname'];
		$lname = $row['lname'];
}
print "$user_id: fname $lname";

?>
Your link that calls user nr one should look like http://you.com/user.php?user_id=1

Posted: Sat Jun 07, 2003 11:42 am
by I3lade
Umm that confused me lol... i just want a code that will make it so when they click the username, it brings up thier info and to do that i need to use

Code: Select all

<a href=\"page.php?varibale=value\">here</a[*code] My row names are id, login(username)and pass what do i put in variable and value???!?

Posted: Sat Jun 07, 2003 11:45 am
by redhair
I3lade wrote:what do i put in variable and value???!?
8O huh>?

Posted: Sat Jun 07, 2003 11:47 am
by I3lade
Ugh look:

Code: Select all

<a href="page.php?varibale=value">here</a>
See the variable=value in that code? what do i replace with them which row names ect?