Php MYSQL

Author Topic: Php MYSQL  (Read 3269 times)

Xatsker

  • Guest
  • Trade Count: (0)
Php MYSQL
« on: 04-21-2010, 16:44:37 »
s there a way to make this more random ?

$result = mysql_query('SELECT * FROM pictures ORDER BY RAND() LIMIT 1');


Offline Nicpoint45

  • Trade Count: (0)
  • Jr. Member
  • **
  • Thank You 3
  • Posts: 55
  • Karma: 3
Re: Php MYSQL
« Reply #1 on: 04-21-2010, 16:45:22 »
If your database is small,you should use RAND() otherwise try another solutions as like mentiones in the link that lukeg gave you

Offline sam

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 1
  • Posts: 20
  • Karma: 3
  • Gender: Male
    • anyquestion.webvertex.co.in
Re: Php MYSQL
« Reply #2 on: 02-07-2012, 23:37:30 »
Use this

$range_result = mysql_query( " SELECT MAX(`id`) AS max_id , MIN(`id`) AS min_id FROM `table` ");
$range_row = mysql_fetch_object( $range_result );
$random = mt_rand( $range_row->min_id , $range_row->max_id );
$result = mysql_query( " SELECT * FROM `table` WHERE `id` >= $random LIMIT 0,1 ");

anyquestion.webvertex.co.in

Offline seoguro

  • Trade Count: (0)
  • Novice
  • *
  • Thank You 5
  • Posts: 0
  • Karma: 0
Re: Php MYSQL
« Reply #3 on: 02-17-2012, 04:06:57 »
thanks for sharing sam! you are good programmer.

 

Related Topics

  Subject / Started by Replies Last post
0 Replies
2026 Views
Last post 10-17-2011, 02:12:57
by manvbf
4 Replies
3124 Views
Last post 07-16-2012, 07:07:34
by sunilkumar
1 Replies
1755 Views
Last post 01-04-2014, 02:37:25
by Luca tall
0 Replies
956 Views
Last post 12-23-2015, 04:45:59
by chinmay.sahoo
0 Replies
659 Views
Last post 11-14-2016, 03:19:21
by aarav