Try:

$result = mysql_db_query ("$DBName","select * from Contacts order by rand()
LIMIT 0,5 ");

As your first example had the '0' and then the '5' after the LIMIT clause, the second 
didn't have 
th any '0'.

Cheers.
Russ

On Fri, 31 Aug 2001 20:59:16 +0100 Seb Frost <[EMAIL PROTECTED]> wrote:

> I know it's documented as rand() but you might want to try random() just in
> case... I'm sure I read that somewhere....
> 
> - seb
> 
> 
> -----Original Message-----
> From: John Hurleston [mailto:[EMAIL PROTECTED]]
> Sent: 31 August 2001 19:18
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Random
> 
> 
> I would like to get the first 5 random entries out of my "mysql" database,
> what would be the correct SELECT option?
> 
> I adjusted this line
> 
> $result = mysql_db_query ("$DBName","select * from Contacts LIMIT 0,5 ");
> which works correctly. :)
> 
> $result = mysql_db_query ("$DBName","select * from Contacts order by rand()
> LIMIT 5 ");
> Doesn't work at all. :(
> 
> 
> Can anyone through any light on this subject.
> 
> Thanks.
> 
> 
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.274 / Virus Database: 144 - Release Date: 23/08/2001
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.274 / Virus Database: 144 - Release Date: 23/08/2001
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

#-------------------------------------------------------#
                                
  "Believe nothing - consider everything"       
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com
                        
#-------------------------------------------------------#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to