I have 1 table. I would like to create an small lottery game.
t1 have data as below.
+---------+------------------+-------------------+
| ID | typeid | createtime |
+---------+------------------+-------------------+
| 1 | 1 | 123456 |
| 2 | 2 | 123123 |
| 3 | 1 | 12312312312 |
| 4 | 1 | 13123123 |
| 5 | 1 | 123dddddaasd123 |
+------------------------------------------------+
I would like to choose the winner when the typeid = 1.
My query like this (actually use query or fetch_all of fetch_first?)
$qsid = DB::fetch_all("SELECT * FROM ".DB::table('t1')." WHERE typeid = 1");
and I would like to use
array_rand to choose winner, so should be like array_rand(1,3,4,5);
then I can use the final result to set the winner. Or any suggestion for other better way?
Thank you.