PDA

View Full Version : PHP Help (again) +REP x 2



myke
10-03-2008, 03:25 PM
Hey, here's the code:


echo ('<center>Welcome <b> $logged[username] </b><br /></center>

This is what's displayed:
Welcome $logged[username]
It should be like 'Myke' or w.e their name is.

and then...


echo ('<a href="members.php?user=$user[username]">$user[username]</a><br />');

Which displays as:
$user[username] (http://login.more-media.org/members.php?user=$user%5Busername%5D)
Which should display a username.

Just an add on to the second one:


{
$getuser = mysql_query("SELECT * from users order by id asc");
while ($user = mysql_fetch_array($getuser))
{
// gets all the users information.
echo ('<a href="members.php?user=$user[username]">$user[username]</a><br />');
// links to a page to view the user's profile.

--ss--
10-03-2008, 04:14 PM
Edit: Nevermind i'm just talking a bunch of nonsense :(.

d17c
10-03-2008, 04:17 PM
The first one should just be:

echo ("<center>Welcome <b> $logged[username] </b><br /></center>");

Second one:

echo ("<a href=\"members.php?user=$user[username]\">$user[username]</a><br />");

Decode
10-03-2008, 04:20 PM
U missed off the ')' from this one


echo ("<center>Welcome <b> $logged[username] </b><br /></center>");

Protege
10-03-2008, 04:28 PM
Usually I would go $info["name"]; or what ever your MySQL col name is, What I've read it looks like your building a members system, but this "while" isn't needed unless your processing the whole system of user names.

I read what D17C and I thought I'd add a bit to it

Old:
echo ("<a href=\"members.php?user=$user[username]\">$user[username]</a><br />"); Mine:
echo("<a href=\"members.php?user=".$user["username"]."\">."$user["username"]."</a><br />");To get one user name:

Original:
$getuser = mysql_query("SELECT * from users order by id asc");
while ($user = mysql_fetch_array($getuser))New:
$getuser = mysql_query("SELECT * from users WHERE id = 'driftpanzy') or die(mysql_error());
$user = mysql_fetch_array($getuser);
## to find what the array is called, or mysql col name just
print_r($user);
## that will show the array its fetched.
echo($user["name"]);
Hope that helped :)

myke
10-03-2008, 04:36 PM
Thanks, I'll +REP you all but I've found a new system now haha.

edit; given out too much :(

Protege
10-03-2008, 04:42 PM
Hope it works well :) Rep me later on :)

myke
10-03-2008, 04:44 PM
Drift, got MSGER?

Protege
10-03-2008, 04:47 PM
As in MSN, Yes, my email is: [email protected]

Want to hide these adverts? Register an account for free!