Re: foreach question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 29, 2008 at 3:25 PM, Jason Pruim <japruim@xxxxxxxxxx> wrote:
>
> function random($random){
>
>        $randomQuery = "SELECT * FROM `current` ORDER BY Rand() LIMIT 2";
>
>        $result = mysql_query($randomQuery);
> $row[] = $result;
>
>
> foreach($row as $key => $value) {
> $random[$key] = $value;
>
> }
>
> return $random;
>
> }//End of function
>
>
> ?>

    You're missing mysql_fetch_array(), mysql_fetch_assoc(), or
something of the like.

    Example:

<?php
// .... code....

 $result = mysql_query($randomQuery);
 $row = mysql_fetch_array($result);

 foreach($row as $k => $v) {
     $random[$k] = $v;
 }

// .... code....
}
?>

-- 
</Daniel P. Brown>
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux