foreach question

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

 



Hey Everyone...

So I am attempting to pull 2 random records from a MySQL database, so I wrote a function which I'll paste below. I had it mostly working with a while() statement, but I wanted to try a foreach to see if I could get the formatting a little bit better.

Basically... What it does is grab 2 records at random from the database, and display the images. What I want is something that looks like this: <img1> VS <img2>

right now though... I'm at a lose to figure out why it's not returning any records but not throwing any errors... Any ideas what I'm missing?

<?PHP
//function for pulling random pictures from the database


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


?>

Any ideas?



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