Domestos
Jun 20 2005, 07:57 PM
Hi all,
Using PHP to retrieve data out of a PHP table called Users
There are 10 fields in the table, but I just want the first three called
user_name
user_pass
user-email
user_name is the primary key...
now - how do i get just these three fields and stick them into php
variables...
I can connect to the database and everything - I just need the Select
Statement and the way to get the query result into PHP variables...
TIA
Andy Mak
Danny Wong
Jun 21 2005, 04:03 AM
HI,
The select statement is
"select user_name, user_pass, user_email from ??? where
user_name='$queryuser'"
$queryuser is the variable contains the user you want to retreive, ???
is the table name.
use mysql_fetch_object() to retreive the row object and use it
$data = mysql_fetch_object($result) ;
echo($data->user_name, $data->user_pass, $user_email) ;
Hopes this can help.
Danny Wong
"Domestos" <[Email Removed]> glsD:J4Gte.29644$%[Email Removed]...
QUOTE |
Hi all,
Using PHP to retrieve data out of a PHP table called Users
There are 10 fields in the table, but I just want the first three called
user_name user_pass user-email
user_name is the primary key...
now - how do i get just these three fields and stick them into php variables...
I can connect to the database and everything - I just need the Select Statement and the way to get the query result into PHP variables...
TIA Andy Mak
|
LaBird
Jun 21 2005, 06:25 AM
Hi,
"Domestos" <[Email Removed]> wrote in message
news:J4Gte.29644$%[Email Removed]...
QUOTE |
Hi all,
Using PHP to retrieve data out of a PHP table called Users
There are 10 fields in the table, but I just want the first three called
user_name user_pass user-email
user_name is the primary key...
now - how do i get just these three fields and stick them into php variables...
I can connect to the database and everything - I just need the Select Statement and the way to get the query result into PHP variables...
|
How about this:
// $link is the returned resource variable from the DB connection statement
$res = mysql_query("SELECT user_name, user_pass, user-email from Users",
$link);
$i = 0;
// fetch each record into the array $arr one by one
while ($arr = mysql_array_fetch($res, MYSQL_ASSOC)) {
$username[$i] = $arr["user_name"] ;
$userpass[$i] = $arr["user_pass"];
$useremail[$i] = $arr["user-email"];
$i++;
}
Best Regards,
LaBird (Benny).
[email: remove all numerals to get the correct one]
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.