Iterate through the resulting rows of a single column select statement.
| From: | Glenn Holden | Date: | Wed, 13 Mar 2002 04:56:39 +0000 |
| Subject: | Iterate through the resulting rows of a single column select statement. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17641@lists.php.net to get a copy of this message | ||
I'm looking for a reasonably simple and fast way to fill an array with the
results of a single column select query.
example results from query:
+-----------+
| productid |
+-----------+
| PS |
| PSLEB |
| MD1 |
| CPSS1 |
| CPSG1 |
| CPSP1 |
| CPSSR |
| CPSGR |
| ST1 |
| STFREE |
+-----------+
desired array:
$arr = array(PS,PSLEB,MD1,CPSS1,CPSG1,CPSSR,CPSGR,ST1,STFREE);
I'm using PHP with MySQL.
I've seen ways to fill an array with an entire single row. But I only need
one value from each row so mysql_query() and mysql_fetch_array() seem like
overkill. Does anyone have a function that might do this already or a
suggestion to get me started?
Ultimate Goal:
Basically, I want to interate through a set of ID's returned by the select
query and perform further querys based on each id in the result. An array
would be a clean way to step through it. If there is a
better/simpler/easier way to do this, please let me know. I'm new to PHP
(but not programming).
Thanks a bunch,
Glenn