Simple php link code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Simple php link code

Post 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.
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Anyone please?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post 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.
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

the profiles are in a mysql db?
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Yea.... but what do i put in my link code?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Its a Select code to select what they inserted into the datbase
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

yea a "id" thats the name of the feild, what would the lihnk look like?
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

like ummm

Code: Select all

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

or something?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post 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
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post 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???!?
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

I3lade wrote:what do i put in variable and value???!?
8O huh>?
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post 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?
Post Reply