Re: Listing all id's in array
| From: | John W. Holmes | Date: | Wed, 28 Apr 2004 20:19:03 +0000 |
| Subject: | Re: Listing all id's in array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184900@lists.php.net to get a copy of this message | ||
From: "Phpu" <phpu@go.ro>
> I want to list all the product id's af the database
> in an array, but i do not how.
>
> I have this script but it is not working:
>
> $model = array();
>
> $query = "SELECT product_id FROM products";
> $result = mysql_query($query) or die("error in query - $query -
".mysql_error());
> while (list($product_id) = mysql_fetch_array($result)) {
> $model = "$product_id";
$model[] = $product_id;
> }
>
> echo "$model";
print_r($model);
FYI, you don't need quotes around a variable when it's by itself. $var =
$value, not $var = "$value".
---John Holmes...