> Hello!!!
> 
> Please, assume I have the following mysql query:
> 
> function get_products() {
> 
> $result = mysql_query("select * from products");
>         while ($row = mysql_fetch_array($result)) {
>                  $prod_id = $row["prod_id"];
>                  $prod_name = $row["prod_name"'];
>                  $prod_price = $row["prod_price"];
>         }
> return $products;
> }
> 
> The question:
> 
> Ok, my $products variable will be an array with all products ???

No, it won't be.

Rewrite the function like this:

function get_products() {
  $result = mysql_query("select * from products");
       $i = 0;
       while ($row = mysql_fetch_array($result)) {
              $products[$i]["prod_id"] = $row["prod_id"];
              $products[$i]["prod_name"] = $row["prod_name"'];
              $products[$i]["prod_price"] = $row["prod_price"];
              $i++;
       }
   return($products);
}

That will return a double scripted array of all the products information. 


- James
http://www.phpbb.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to