Jump to content

Efficiently Selecting Rows Randomly - Solved With Our Thanks In The Last Post


niche

Recommended Posts

This script is based on the creation of a column that's repopulated each time the script runs. It would be great to randomly re-order just the mysql resource from the query. Is that even possible? Here's my script:

require_once "connect_to_mysql.php";mysql_query("UPDATE preplan set random_num = RAND()") or die(mysql_error());require_once "connect_to_mysql.php";$act_directs = mysql_query("SELECT * FROM preplan WHERE TIMESTAMP(NOW()) BETWEEN TIMESTAMP(begin) AND TIMESTAMP(end) ORDER BY random_num ASC") or die(mysql_error());$act_directs2 = mysql_fetch_array($act_directs);$id = $act_directs2['id'];echo $id;

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...