Jump to content

Fetching a random value from query results


Rauvnos

Recommended Posts

Heya folks, new to phpfreaks.  I just started learning php a couple of weeks ago.  I tried searching for a resolution on these boards first, but couldn't quite find what I was looking for.

 

I'm pulling a single column of data from a query.  I need to pull a random value out of that.

 

So, let's say I had a table 'people' and I was pulling their 'id' column.  I want to grab a random ID out of that column.  I've tried using array_rand against the result of the query, but couldn't figure out how to do it right.  Mind, I'm *only* pulling that one column.  So I don't think I need to worry about stripping out other columns from the results.

 

Thoughts?

 

(And thanks in advance.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.