Page 2 of 4
Posted: Sat Jun 07, 2003 11:49 am
by redhair
Posted: Sat Jun 07, 2003 11:50 am
by I3lade
Ok,but how do i make it so it finds the user id automactily? Like so they click bob user id 1 and then click joe with user id 2
Posted: Sat Jun 07, 2003 12:05 pm
by redhair
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;
?>
Posted: Sat Jun 07, 2003 3:34 pm
by I3lade
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
Posted: Sat Jun 07, 2003 4:34 pm
by I3lade
Anyone please?
Posted: Sat Jun 07, 2003 4:37 pm
by delorian
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:
Code: Select all
<a href="lookup.php?memberid=<?=$row[login]->id?"> $row[login] </a>
it should be something like this:
Code: Select all
<a href="lookup.php?memberid=".$row[id]."">".$row[login]."</a>
if you want to find the user by its id.
But of course user redhair already wrote something similar and equaly good...
trying
Posted: Sat Jun 07, 2003 4:49 pm
by phpScott
from RedHair
<?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;
?>
will create a list of links like
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>
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
Code: Select all
<?php
$user_id=$GET['user_id'];
print "welcome $user_id to this page";
?>
which would print out
welcom bob to this page
assuming that you orginaly clicked on the link that said bob login
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.
Posted: Sat Jun 07, 2003 5:04 pm
by I3lade
It still dosnt work.. its my page, lookup.php thats the problem...
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!");
};
?>
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...
Posted: Sat Jun 07, 2003 5:13 pm
by redhair
It's getting amusing now..
Wait..let me try this..
Posted: Sat Jun 07, 2003 5:14 pm
by redhair
I3lade ARE YOU READING ANY OF THIS?
Posted: Sat Jun 07, 2003 5:16 pm
by I3lade
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:
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]
Posted: Sat Jun 07, 2003 5:19 pm
by I3lade
Hopfuily it will help my code to work thanks and sorry again
Posted: Sat Jun 07, 2003 5:23 pm
by I3lade
Hrm i cant get it to work could you please give me another chance and try to help me fix my lookup.php? I fixed the link thanks to you guys... please just give me one more chance..
Posted: Sat Jun 07, 2003 5:34 pm
by I3lade
Well if you don't want to help ill understand but im sorry and i really need help, im a newb to php..
Posted: Sat Jun 07, 2003 5:44 pm
by phpScott
<?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!");
};
?>
first thing you are missing a > after your closing center tag.
second try this
Code: Select all
$sql="SELECT * FROM members where id='$id'";
$query = mysql_query($sql);
echo "sql is $sql<br />";
to see your sql query and run that agianst the db directly to see if there is a problem with your query.
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');
read
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