php3-list | 199903
Date: 03/23/99
- Next message: a. otto: "[PHP3] date/time problem"
- Previous message: Hans Anderson: "[PHP3] HTML 4.0 stuff"
- In reply to: Daevid Vincent: "[PHP3] function to convert db fields to php variables?"
- Next in thread: CIMPOESU Teodor: "Re: [PHP3] function to convert db fields to php variables?"
- Reply: CIMPOESU Teodor: "Re: [PHP3] function to convert db fields to php variables?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, 22 Mar 1999, Daevid Vincent wrote:
> Does anybody have a little function or some code that quickly takes all the
> if ($result > 0)
> {
> $first_name = mysql_result($result,0,"first_name");
> $last_name = mysql_result($result,0,"last_name");
> $email = mysql_result($result,0,"email");
> $address = mysql_result($result,0,"address");
> $city = mysql_result($result,0,"city");
> $state = mysql_result($result,0,"state");
> $zip = mysql_result($result,0,"zip");
> $voice = mysql_result($result,0,"voice");
> $browser_list = mysql_result($result,0,"browser_list");
> $os_list = mysql_result($result,0,"os_list");
> $cpu = mysql_result($result,0,"cpu");
> $mhz = mysql_result($result,0,"mhz");
> $ram = mysql_result($result,0,"ram");
> $videocard = mysql_result($result,0,"videocard");
> $dxver = mysql_result($result,0,"dxver");
> }
Try this. It will not only be cleaner code, but much more efficient.
Of course, the list of variables will have to be in the same order
in which they appear in the result.
list($first_name, $last_name, $email, $address, $city,
$state, $zip, $voice, $browser_list, $os_list,
$cpu, $mhz, $ram, $videocard, $dxver) =
mysql_fetch_row($result);
Or, instead of individual variables, you can use an associative
array, which would still allow you to specify the fields by name:
$fields = mysql_fetch_array($result);
After that, your fields are addressed as:
echo $fields['first_name'];
echo $fields['last_name'];
etc.
--Dan
____________________________________________________________________________
Daniel G. Delaney * Dionysos <email protected> * www.Dionysia.org/~dionysos
PGP Public Key: http://Dionysia.org/~dionysos/pgp5.html
"Only two things are infinite: the universe and stupidity--
and I'm not sure about the former."
--Albert Einstein
-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>
- Next message: a. otto: "[PHP3] date/time problem"
- Previous message: Hans Anderson: "[PHP3] HTML 4.0 stuff"
- In reply to: Daevid Vincent: "[PHP3] function to convert db fields to php variables?"
- Next in thread: CIMPOESU Teodor: "Re: [PHP3] function to convert db fields to php variables?"
- Reply: CIMPOESU Teodor: "Re: [PHP3] function to convert db fields to php variables?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

