SELECT * FROM TABLE WHERE HOUR(time) BETWEEN 1 AND 2;

This query brings all records between 1 and 2 o’clock according to time field of you table. (time = The DB field which you save the time)

You can check if a record exist in a specific table of database in MySQL with the code block below:

if(mysql_num_rows(mysql_query("SELECT * FROM reports WHERE reportID = '$reportNUM'"))){
// Code inside if block if reportID is already there
}

Bunun için;

çekeceğiniz query’nin sonunda  şunlar ekliyorsunuz:(Kalın olarak yazılan kismi) 

$sorgu=mysql_query(“SELECT * FROM table ORDER by rand() LIMIT 1“);

Daha fazlası icin bu makaleyi inceleyiniz:

http://www.learningmovabletype.com/a/001037random_quotes/