You cannot do this: $row[] = $result; You need to loop around this: $row = mysql_fetch_assoc($result); Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Jason Pruim wrote: > 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