redhair wrote:Your link that calls user nr one should(..or could) look like http://you.com/user.php?user_id=1
Simple php link code
Moderator: General Moderators
- redhair
- Forum Contributor
- Posts: 300
- Joined: Fri May 30, 2003 4:36 pm
- Location: 53.23N-6.57E
- Contact:
You should retreive the id's and names from the database first, with that create a list, like this example.
Code: Select all
<?php
$query = "SELECT id,login FROM user_table ORDER BY id DESC";
$result = MYSQL_QUERY($query);
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$login = $row['login'];
$users .= "<a href='user.php?user_id=" . $id . "'>" . $login . "</a><br>\n";
}
print $users;
?>I cant find my variable !
<?
mysql_connect("localhost","bladegames", "***");
mysql_select_db("bladegames");
echo "<table>
<tr><td>Number</td><td>Username</td><td>Email</td></tr>
";
$query = mysql_query("SELECT * FROM members ORDER BY id");
while($row=mysql_fetch_array($query))
{
echo "<tr><td>$row[id]</td><td>$row
<a href=\"lookup.php?memberid=<?=$row[login]->id?\"> $row[login] </a></td><td>
$row[email] </td></tr>";
}
}else{
printf("Your not logged in, plz login again");
};
?>
I think its in the link not sure.. The link is:
Code:
a href=\"lookup.php?memberid=<?=$row[login]->id?\"> $row[login] </a
<?
mysql_connect("localhost","bladegames", "***");
mysql_select_db("bladegames");
echo "<table>
<tr><td>Number</td><td>Username</td><td>Email</td></tr>
";
$query = mysql_query("SELECT * FROM members ORDER BY id");
while($row=mysql_fetch_array($query))
{
echo "<tr><td>$row[id]</td><td>$row
<a href=\"lookup.php?memberid=<?=$row[login]->id?\"> $row[login] </a></td><td>
$row[email] </td></tr>";
}
}else{
printf("Your not logged in, plz login again");
};
?>
I think its in the link not sure.. The link is:
Code:
a href=\"lookup.php?memberid=<?=$row[login]->id?\"> $row[login] </a
Did you ever bothered to read what people wrote to you
Because I think you did not.
I've told you that there is an mistake here:
it should be something like this:
if you want to find the user by its id.
But of course user redhair already wrote something similar and equaly good...
I've told you that there is an mistake here:
Code: Select all
<a href="lookup.php?memberid=<?=$row[login]->id?"> $row[login] </a>Code: Select all
<a href="lookup.php?memberid=".$row[id]."">".$row[login]."</a>But of course user redhair already wrote something similar and equaly good...
trying
from RedHair
bob login
joe login
bill login
which in html code look like
So now because you have dynamically created the links each individual link will now pass along the value of each individual user_id as a parameter to the next page.
say the page is called user.php same name as in the link you would do something like
which would print out
is that any help of what is going on.
phpScott
Please read twigletmac link on posting questions and asking for help.
It is good reading and will allow us to help you better.
ps. thanks twig for lock some of the other posts as it seemed to be getting a little out of hand.
will create a list of links like<?php
$query = "SELECT id,login FROM user_table ORDER BY id DESC";
$result = MYSQL_QUERY($query);
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$login = $row['login'];
$users .= "<a href='user.php?user_id=" . $id . "'>" . $login . "</a><br>\n";
}
print $users;
?>
bob login
joe login
bill login
which in html code look like
Code: Select all
<a href='user.php?user_id=bob'>bob login</a><br>
<a href='user.php?user_id=joe'>joe login</a><br>
<a href='user.php?user_id=bill'>bill login</a><br>say the page is called user.php same name as in the link you would do something like
Code: Select all
<?php
$user_id=$GET['user_id'];
print "welcome $user_id to this page";
?>assuming that you orginaly clicked on the link that said bob loginwelcom bob to this page
is that any help of what is going on.
phpScott
Please read twigletmac link on posting questions and asking for help.
It is good reading and will allow us to help you better.
ps. thanks twig for lock some of the other posts as it seemed to be getting a little out of hand.
It still dosnt work.. its my page, lookup.php thats the problem...
lookup.php:Otherwise thanks for the help with the link, now that thats working i got to make this work otherwise it dsiplays Hobbies: Profile:
with nothing there.. Oh and thanks for locking those other threads i tried to delte them but i guess i cant...
lookup.php:
Code: Select all
<?php
session_start();
if($logged==1){
?>
<?
mysql_connect("localhost","bladegames", "***");
mysql_select_db("bladegames");
$query = mysql_query("SELECT * FROM members where id='$id'");
{
echo "
<center> $rowїlogin] 's Look Up </center
<font color="black" size=2>Hobbies: $rowїphob] <br>
<font color="black" size=2>Other Information: $rowїprofile] <br>";
}
}else{
printf("Your not logged in, please login again, or register today!");
};
?>with nothing there.. Oh and thanks for locking those other threads i tried to delte them but i guess i cant...
Im going to use one of your eiarly posts:
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
PHP:
Your link that calls user nr one should look like http://you.com/user.php?user_id=1
Yea i just went back and read all of it i missed im really sorry evryone, im just trying to get some help ok redhiar im going to try to use on of the eairlyier posts u posted to help The post im talking about is:
[/quote]
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
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
Yea i just went back and read all of it i missed im really sorry evryone, im just trying to get some help ok redhiar im going to try to use on of the eairlyier posts u posted to help The post im talking about is:
[/quote]
first thing you are missing a > after your closing center tag.<?php
session_start();
if($logged==1){
?>
<?
mysql_connect("localhost","bladegames", "***");
mysql_select_db("bladegames");
$query = mysql_query("SELECT * FROM members where id='$id'");
{
echo "
<center> $row[login] 's Look Up </center
<font color=\"black\" size=2>Hobbies: $row[phob] <br>
<font color=\"black\" size=2>Other Information: $row[profile] <br>";
}
}else{
printf("Your not logged in, please login again, or register today!");
};
?>
second try this
Code: Select all
$sql="SELECT * FROM members where id='$id'";
$query = mysql_query($sql);
echo "sql is $sql<br />";you have a $query then you jump right into $row[phob]
There needs to be some sort of transition between the two
read http://www.mysql.com/doc/en/mysql_query.html
to understand mysql_query()
You now need to fecht the data
as in
Code: Select all
$phob=mysql_result($query, 0, 'phob');http://ca2.php.net/manual/en/function.mysql-result.php
phpScott
get to know http://www.mysql.com and http://www.php.net as they are wonderful resources for research and learning
phpScott