Turntable draw randomly returns a turntable radian
Probabilities can be defined by themselves
lottery_get.php
' Error ', ' msg ' = ' + ' connection timed out, please reopen the page. '); exit;} $user _id = $_session[' zaszh_user_id '];*/$user _id = 1; Test with//turntable area $arr_area = Array (' 0 ' = = Array (' Min_angle ' =>1, ' max_angle ' =>45, ' prize ' = ' millet '), ' 1 ' = = Array ( ' Min_angle ' =>46, ' max_angle ' =>90, ' prize ' = ' Pat '), ' 2 ' = = Array (' Min_angle ' =>91, ' Max_angle ' =>135, ' Prize ' = ' 10 yuan phone call '), ' 3 ' = = Array (' Min_angle ' =>136, ' max_angle ' =>180, ' prize ' = ' 5 Yuan '), ' 4 ' = = Array (' Min_angle ' =>181, ' max_angle ' =>225, ' prize ' = ' Thank you for participating '), ' 5 ' = = Array (' Min_angle ' =>226, ' max_angle ' = ' Prize ' + ' Thank you for participating '), ' 6 ' = = Array (' Min_angle ' =>271, ' max_angle ' =>315, ' prize ' = ' Thank you for participation '), ' 7 ' = Array (' Min_angle ' =>316, ' max_angle ' =>360, ' prize ' = ' Thank you for Participation '));//Selected Area $area_selected = Array ();//Random Extraction $num_ Rand = Mt_rand (1,10), switch ($num _rand) {//Xiaomi Case 1: $area _selected = $arr _area[0]; break;//Pat Case 2: $area _selected = $a RR_AREA[1]; break;//10 Yuan Phone case 3: $area _selected = $arr _area[2]; break;//5 Yuan Phone case 4: $area _selected = $arR_AREA[3]; break;//Thank you for participating Default:switch (Mt_rand (1,4)) {Case 1: $area _selected = $arr _area[4]; Break;case 2: $area _selected = $arr _ AREA[5]; Break;case 3: $area _selected = $arr _area[6]; Break;case 4: $area _selected = $arr _area[7]; break;} break;} echo $area _selected[' Prize '];require (' connect_database.php ');//minus Answer points $mysqli->query ("Update zaszh_user set answer_points=answer_points-5 where id= ' {$user _id} ' and answer_points>=5 '); if ($mysqli->affected_rows) {//have points/ /Record integral consumption $mysqli->query ("INSERT INTO Zaszh_answer_points_consume (user_id,points_consume,consume_for,create_date Values (' {$user _id} ', 5, ' lottery ', Unix_timestamp (now))), switch ($area _selected[' Prize ']) {case ' millet ': $mysqli- >query ("Update zaszh_prize_surplus set surplus=surplus-1 where prize= ' millet ' and surplus>0"); if ($mysqli Affected_rows) {//have the remaining $mysqli->query ("INSERT into Zaszh_award (user_id,prize,create_date) VALUES (' {$user _id} ', ' Xiaomi ', Unix_timestamp (now ())), if ($mysqli->affected_rows) {echo json_encode (' Status ' = = ' success ', ' msg ' = ' millet '); else{//Award failed}}else{//no remaining}break;case ' Pat ': $mysqli->query ("Update zaszh_prize_surplus set surplus=surplus-1 where Prize= ' and surplus>0 '), if ($mysqli->affected_rows) {//have remaining $mysqli->query ("INSERT INTO Zaszh_award (user_ Id,prize,create_date) VALUES (' {$user _id} ', ' Pat ', Unix_timestamp (now)) "), if ($mysqli->affected_rows) {echo JSON _encode (Array (' status ' = ' success ', ' msg ' = ' clap ')); else{//Award failed}}else{//no remaining}break;case ' 10 Yuan phone call ': $mysqli->query ("Update zaszh_telephone_charge_surplus set Charge_ SURPLUS=CHARGE_SURPLUS-10 where Date=substring (now (), 1,10) and charge_surplus>=10 "); if ($mysqli->affected_ rows) {//have the remaining $mysqli->query ("INSERT into Zaszh_award (user_id,prize,create_date) VALUES (' {$user _id} ', ' $10 phone call ', Unix _timestamp (now ())), if ($mysqli->affected_rows) {echo json_encode (' status ' = ' success ', ' msg ' = ') 10 yuan));} else{//Award failed}}else{//no remaining}break;case ' 5 yuan phone call ': $mysqli->query ("Update zaszh_telephone_charge_surplus set CharGe_surplus=charge_surplus-5 where Date=substring (now (), 1,10) and charge_surplus>=5 "); if ($mysqli->affected_ rows) {//have remaining $mysqli->query ("INSERT into Zaszh_award (user_id,prize,create_date) VALUES (' {$user _id} ', ' $5 call ', Unix_ Timestamp (now ())), if ($mysqli->affected_rows) {echo json_encode (' status ' = ' success ', ' msg ' = ') 5 yuan));} else{//Award failed}}else{//no remaining}break;default:echo json_encode (' status ' = ' success ', ' msg ' = ' Thank you '));}} else{//No points echo json_encode (array (' status ' = ' error ', ' msg ' = ' = ' your points are insufficient. '));} $mysqli->close ();
The above introduces the PHP Carousel draw demo, including the content, I hope that the PHP tutorial interested in a friend helpful.