first I would suggest you get the largest value from the auto increment field (maybe use last_insert_id()). Then use rand(1,$cno_max) three times to get three random cno numbers, then "select ... from ... where cno=$val1 or cno=$val2 or cno=$val3" should return the three values. rand() can also be directly in the sql statement. Also manual suggests using mt_rand instead of rand for better performance. K.Sakkas Ryan A wrote: > Hey, > need some advise on what would be the best way to do this: > > I have a table with these fields: > cno (just a auto_increment field), > username, > sex (2 values: man, woman), > has_pic (0=no,1=yes), > pic_name > > I need to randomly get 3 womens pictures and one guys picture from the above > table... > I know I need to use rand() and i thought maybe shuffle() but am getting a > bit lost in the logic part...help please? > > Thanks, > Ryan > > > -- Kyriacos Sakkas Netsmart Development Team Tel: + 357 22 452565 Fax: + 357 22 452566 kyriacos(at)netsmart.com.cy http://www.netsmart.com.cy Taking Business to a New Level! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php