[thelist] this issue of ala (was: Spaking about standards...)

Jay Greenspan jay at trans-city.com
Tue Feb 20 16:45:55 CST 2001


> hi jay
> 
> the listapart article did receive good airplay hereabouts -- the thread
> that carried most of it was "[thelist] Tip o'the day (x2)"
> 

Indeed. Thanks. Serves me right for spending time away from my email client.
To make up for the added noise, I'll throw in a tip:

<tip type="PHP">
You can use the list() function to assign any array elements to scalar
variables. I like to use it with queries. Rather than assigning a row
gathered with mysql_fetch_array() to an array and getting the items with
array syntax ($row["first_name"]), I prefer to do it (usually) like so:

$query = "select fname, lname from users order by lname";
$result=mysql_query($query) or
    die (mysql_error());
while (list(fname, lname) = mysql_fetch_array($result))
{
    echo "$fname $lname";
}

</tip>





More information about the thelist mailing list