RE: [PHP] Excracting Data From MySql
| From: | Alex Dowgailenko | Date: | Wed, 23 Jan 2002 08:12:34 +0000 |
| Subject: | RE: [PHP] Excracting Data From MySql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81652@lists.php.net to get a copy of this message | ||
if it's from MySQL, use mysql_fetch_array() instead of mysql_fetch_rows().
eg:
$sql = mysql_query("SELECT cars, planes, boats FROM transportation") or
die(mysql_error());
while ($transportation = mysql_fetch_array($sql)) {
echo 'Car: '.$transportation["cars"].'<br>';
echo 'Plane: '.$transportation["planes"].'<br>';
echo 'Boat: '.$transportation["boats"].'<br>';
}
the keys for the array created by mysql_fetch_array() are that of the colum
names.
As for sorting out your variables, use arrays to group together variables of
a certain type.
For instance, as opposed to having twenty different variables for each type
of car,
try $carTypes["model"] or something like that.
And don't forget to make sure you have approriate names for your variables.
An array for people's email addresses shouldn't be called
$iwishiknewjustwhereiwasgoing.
> -----Original Message-----
> From: Philip J. Newman [mailto:newmanpj@philipsdomain.com]
> Sent: January 23, 2002 2:43 AM
> To: php-general@lists.php.net
> Subject: [PHP] Excracting Data From MySql
>
>
> Whats the best way to remember what all your veriables are when
> working with heaps of them.
>
> Philip J. Newman
> Philip's Domain - Internet Project.
> http://www.philipsdomain.com/
> info@philipsdomain.com
> Phone: +64 25 6144012
>