[thelist] array of results in PHP

Andrew Maynes andrew at humanbehaviour.co.uk
Mon Feb 24 11:06:00 CST 2003


Hi Kae

I having been reading up mysql_fetch_array and it appears I need to change my
existing code to something like this:

while ( $myrow = mysql_fetch_array($result) )

printf("<table border=0 cellspacing=0 cellpadding=0><tr><td><p>Author :
%s</td></tr>
<tr><td><p>Message : %s</p></td></tr>
<tr><td><p>Date : %s</p></td></tr></table><br><hr><br>", $myrow["name"],
$myrow["message"], $myrow["time"]);

}

Am I right?  Is this why the query isn't working do you think?

Apologises for the emails x many your help is very much appreciated :)
Andrew



>-----Original Message-----
>From: thelist-admin at lists.evolt.org
>[mailto:thelist-admin at lists.evolt.org]On Behalf Of Kae Verens
>Sent: 24 February 2003 16:06
>To: thelist at lists.evolt.org
>Subject: Re: [thelist] array of results in PHP
>
>
>Erik Mattheis wrote:
>> So, I'm wondering if this can easily be done in PHP:
>>
>> $all_results = mysql_[somefunction]($my_query);
>>
>> $all_results[1]['person_id'] = person_id in the first row
>> $all_results[2]['name'] = name in the second row
>> etc.
>
>as far as I know, there isn't a function for that. Here's some code that
>should do it.
>
>$q=mysql_query('select person_id,name from theTable');
>$all_results=array();
>while($all_results[]=mysql_fetch_array($q));
>
>$all_results[0]['person_id'] will be the person_id in the first row
>(indices start with 0, not 1)
>
>--
>Kae Verens               _______\_   webworks.ie
>pay:  www.webworks.ie       _____\\__   webhosts
>play: www.contactjuggling.org  ___\\\___  design
>  kae: kverens.contactjuggling.org _\\\\____ code
>
>--
>* * Please support the community that supports you.  * *
>http://evolt.org/help_support_evolt/
>
>For unsubscribe and other options, including the Tip Harvester
>and archives of thelist go to: http://lists.evolt.org
>Workers of the Web, evolt !
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.456 / Virus Database: 256 - Release Date: 18/02/2003
>




More information about the thelist mailing list