|
Posted by LaBird on 06/21/05 10:25
Hi,
"Domestos" <never.you@mind.net> wrote in message
news:J4Gte.29644$%21.12323@newsfe2-gui.ntli.net...
> 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]
>
> TIA
> Andy Mak
>
>
Navigation:
[Reply to this message]
|