[thelist] array of results in PHP

Kae Verens kverens at contactjuggling.org
Mon Feb 24 10:10:01 CST 2003


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




More information about the thelist mailing list