jetlife76 Posted November 27, 2011 Share Posted November 27, 2011 I have a script for a Power Ball game that i recieved when i was asking for help on the one i am working on. The guy that gave me the code didnt answer the question i was asking about my old code, instead he gave me this one and he hasn't reaponded in the past couple of days. I am new to php and i'm confused as to what the front page should look like on his code as he only gave me the php. i see that he has the output going to tables but i dont understand how to create a front page to see the code working. When i copied and pasted his code i only get a page with the lottery numbers and my numbers. i am trying to use drop down lists on my page with a quick pick option and a submit button for the lists. Hope that is clear enough for now Thanks in advance if anyone can help me or explain the way to create the page. Her's the code he gave me <?php //CONFIG VARIABLES $no_balls = 5; $first_ball = 1; $last_ball = 59; $first_powerball = 1; $last_powerball = 49; $diff_powerball = true; //GET THE RANDOM NUMBERS AND POWERBALL function getNumbers($no_balls,$first_ball,$last_ball,$first_powerball,$last_powerball,$diff_powerball){ $powerball = mt_rand($first_powerball,$last_powerball); $all_balls = range($first_ball,$last_ball); if(!$diff_powerball){ $all_balls_remove_key = array_search($powerball, $all_balls); unset($all_balls[$all_balls_remove_key]); } shuffle($all_balls); $picked_balls = array_slice($all_balls,0,$no_balls); $pciked_balls = sort($picked_balls); return array('picked'=>$picked_balls,'powerball'=>$powerball); } //SET bad flag $bad = false; //GET LOTTERY RESULTS $lotteryBalls = getNumbers($no_balls,$first_ball,$last_ball,$first_powerball,$last_powerball,$diff_powerball); //GET MY BALLS - AUTO OR MANUAL if(!isset($_POST['quickP'])){ $myBalls = getNumbers($no_balls,$first_ball,$last_ball,$first_powerball,$last_powerball,$diff_powerball); }else{ if(isset($_POST['Power']) && intval($_POST['Power']) >= $first_powerball && intval($_POST['Power']) <= $last_powerball){ $myBalls['powerball'] = intval($_POST['Power']); }else{ $bad = true; } for($x=1;$x=$no_balls;$x++){ if(isset($_POST['num'.$x]) && intval($_POST['num'.$x]) >= $first_ball && intval($_POST['num'.$x]) <= $last_ball){ $myBalls['picked'][] = intval($_POST['num'.$x]); }else{ $bad = true; } } } if(!$bad){ //GET NUMBER OF MATCHES FOR NORMAL NUMBERS $no_matches = count(array_intersect($myBalls['picked'],$lotteryBalls['picked'])); //SEE IF POWERBALLS MATCH $power_match = ($myBalls['powerball'] == $lotteryBalls['powerball']); //BUILD TABLE FOR RESULT OUTPUT $lotto_table_balls = ""; $my_table_balls = ""; $table = '<table><thead><tr><th> </th>'; for($x=0;$x<$no_balls;$x++){ $table .= '<th>Ball' . ($x + 1) .'</th>'; $class = (in_array($myBalls['picked'][$x],$lotteryBalls['picked'])) ? ' class="match"' : ''; $lotto_table_balls .= "<td>{$lotteryBalls['picked'][$x]}</td>"; $my_table_balls .= "<td{$class}>{$myBalls['picked'][$x]}</td>"; } $class = ($myBalls['powerball'] == $lotteryBalls['powerball']) ? ' class="match"' : ''; $table .= "<th>Powerball</th></tr></thead><tbody><tr><th>LOTTO</th>" . $lotto_table_balls . "<td>{$lotteryBalls['powerball']}</td></tr><tr><th>MY NUMBERS</th>" . $my_table_balls . "<td{$class}>{$myBalls['powerball']}</td></tr></tbody></table>"; }else{ $table = "You didn't enter the correct numbers."; } ?> <style>.match{background-color: red;}</style> <?php echo $table;?> Quote Link to comment https://forums.phpfreaks.com/topic/251908-lottery-script/ Share on other sites More sharing options...
jetlife76 Posted November 27, 2011 Author Share Posted November 27, 2011 the output should also show a message saying how many numbers match and how much the user won or not. the script i have of my own does all this but when quick pick is selected, it doesnt check to see if any matches were found. I don't know what else to do, i've been on this program for weeks, and it seems like everytime i get help everyone wants to give me a completely different code that i don't understand, or suggests that i rewrite the code but with no suggestions on how to do it. Not asking for a teacher, just someone to help me with the logic and syntax a bit. Quote Link to comment https://forums.phpfreaks.com/topic/251908-lottery-script/#findComment-1291653 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.