Re: foreach question

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

 




On Jul 29, 2008, at 3:33 PM, Daniel Brown wrote:

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....
}
?>



Added that, then changed how I was calling it and it works great now... Thanks for looking... The problem was definitely between the chair and the keyboard on this one.




--
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