Can someone whos good with php help me...
Moderator: General Moderators
Can someone whos good with php help me...
How would i use SELECT syntax to select a specific users data and post it like it would say:
Welcome <USERNAME>!
how do i do that, i know i have to get thier id and stuff but how? Please help.
Welcome <USERNAME>!
how do i do that, i know i have to get thier id and stuff but how? Please help.
Last edited by I3lade on Mon Jun 16, 2003 5:51 pm, edited 1 time in total.
Let's say you select just the name from the database. You do something like:
Then you do something like:
You may want to have a look at the mysql_fetch_* commands. Hope that helps.
Code: Select all
<?php
$row = mysql_fetch_row($query, $db);
?>Code: Select all
<?php
echo "Welcome ".$row['0'];
?>What do you want to do with the id? Maybe something like:
Code: Select all
<?php
echo "Welcome ".$row['username'];
echo "Your ID is ".$row['id'];
?>So i do:
Like that?
Code: Select all
<?php
$row = mysql_fetch_row($query, $zeopets);
?>
<?php
echo "Welcome ".$rowї'username'];
echo "Your ID is ".$rowї'id'];
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Unless you're in a double quoted string because:
will give you a parse error (or an undefined index notice depending which version of PHP you've got).
is fine.
Mac
Code: Select all
echo "Logged in as: $row['username'] <br>";Code: Select all
echo "Logged in as: $row[username] <br>";Mac