Re: Query result column to array
| From: | Rafael Mora | Date: | Wed, 30 Aug 2006 15:16:08 +0000 |
| Subject: | Re: Query result column to array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241238@lists.php.net to get a copy of this message | ||
Hi!!
What I do is just this:
$_ar = array();
while($_field = mysql_fetch_row($_result))
{$_aloft["$_field[0]"] = "$_field[1]";}
while(list($_key,$_val) = each($_ar))
On 8/30/06, Christopher Watson <skygeex@gmail.com> wrote:
I'm looking for a native method for taking all of the values from one column of a query result and creating an array of those values. Procedurally, I'd tend to want to do this: <?php $my_id_array = array(); $query_result = $_DB->query("SELECT my_id FROM my_table"); while ($row = $query_result->fetchRow()) $my_id_array[] = $row['my_id']; ?> Heck, ColdFusion has the ValueList function which does exactly what I want (of course, it returns a delimited list [string], not a native array, but the one-step method is there). Is there anything in PHP-land that does that? Or am I pretty much stuck using some variation of the code above? Christopher Watson Principal Architect The International Variable Star Index (VSX) http://vsx.aavso.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php