Jump to content

Falky2015

New Members
  • Posts

    3
  • Joined

  • Last visited

Falky2015's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried using your system and come up with this which works exactly how I want it to, its bloody long though LOL and took ages to code but with your code it made it a little easier. Iv tested this out and works a charm every single time so with your help and my way of making things 10x harder than they should be Iv fixed my issues and thanks for all your help ;-) <?php //random numbers $arr = array(); while ( count($arr) < 6 ) { $x = mt_rand(1,24); if ( !in_array($x,$arr) ) { $arr[] = $x; asort($arr); } } foreach($arr as $x){ $numbers[]=$x." "; } for($i2=0;$i2<6;$i2++){ //start cycle if($i2=="0"){ $no01=$numbers[$i2]; } if($i2=="1"){ $no02=$numbers[$i2]; } if($i2=="2"){ $no03=$numbers[$i2]; } if($i2=="3"){ $no04=$numbers[$i2]; } if($i2=="4"){ $no05=$numbers[$i2]; } if($i2=="5"){ $no06=$numbers[$i2]; } //end cycle } $sql91="SELECT * FROM $table WHERE draw='$draw'"; $result91=mysql_query($sql91); while($rows91=mysql_fetch_array($result91)){ $THEuser=$rows91['user']; //END THE RANDOM NUMBERS NOW--------- $query1= "SELECT user, COUNT(*) as num_correct FROM lotto WHERE draw='$draw' AND user='$THEuser' AND no01 IN (".implode(',',$arr).")"; $result1 = mysql_query($query1) or die($query1."<br/><br/>".mysql_error()); while($rows1=mysql_fetch_array($result1)){ if($rows1['num_correct']==1){ $MEMBER01=1; }else{ $MEMBER01=0; } } $query2= "SELECT user, COUNT(*) as num_correct FROM lotto WHERE draw='$draw' AND user='$THEuser' AND no02 IN (".implode(',',$arr).")"; $result2 = mysql_query($query2) or die($query2."<br/><br/>".mysql_error()); while($rows2=mysql_fetch_array($result2)){ if($rows2['num_correct']==1){ $MEMBER02=1; }else{ $MEMBER02=0; } } $query3= "SELECT user, COUNT(*) as num_correct FROM lotto WHERE draw='$draw' AND user='$THEuser' AND no03 IN (".implode(',',$arr).")"; $result3 = mysql_query($query3) or die($query3."<br/><br/>".mysql_error()); while($rows3=mysql_fetch_array($result3)){ if($rows3['num_correct']==1){ $MEMBER03=1; }else{ $MEMBER03=0; } } $query4= "SELECT user, COUNT(*) as num_correct FROM lotto WHERE draw='$draw' AND user='$THEuser' AND no04 IN (".implode(',',$arr).")"; $result4 = mysql_query($query4) or die($query4."<br/><br/>".mysql_error()); while($rows4=mysql_fetch_array($result4)){ if($rows4['num_correct']==1){ $MEMBER04=1; }else{ $MEMBER04=0; } } $query5= "SELECT user, COUNT(*) as num_correct FROM lotto WHERE draw='$draw' AND user='$THEuser' AND no05 IN (".implode(',',$arr).")"; $result5 = mysql_query($query5) or die($query5."<br/><br/>".mysql_error()); while($rows5=mysql_fetch_array($result5)){ if($rows5['num_correct']==1){ $MEMBER05=1; }else{ $MEMBER05=0; } } $query6= "SELECT user, COUNT(*) as num_correct FROM lotto WHERE draw='$draw' AND user='$THEuser' AND no06 IN (".implode(',',$arr).")"; $result6 = mysql_query($query6) or die($query6."<br/><br/>".mysql_error()); while($rows6=mysql_fetch_array($result6)){ if($rows6['num_correct']==1){ $MEMBER06=1; }else{ $MEMBER06=0; } } $TOTALMEMBER=$MEMBER01+$MEMBER02+$MEMBER03+$MEMBER04+$MEMBER05+$MEMBER06; echo "$THEuser got $TOTALMEMBER numbers correct for draw $draw<br><br>"; } ?>
  2. Thanks for the reply, yeah I just have the database setup like this as it was easier to display the results per person, I will give yours a go, but once I have how many winning numbers they have, I need to highlight their winning numbers on a results page and also for 3 or more numbers correct echo a prize amount eg, 3 will get 10 points, 4 will get 50, 5 will get 500, 6 will get 5000 points: Tables - id - user - no01 - no02 - no03 - no04 - no05 - no06 1 jace 5 23 12 18 20 23 <? $TOTALMEMBER=$MEMBER01+$MEMBER02+$MEMBER03+$MEMBER04+$MEMBER05+$MEMBER06; //PROCESS IF THE INDIVIDUAL WON PRIZES if($TOTALMEMBER==1){ } if($TOTALMEMBER==2){ } if($TOTALMEMBER==3){ $sql5="UPDATE winners SET points=points+'10' WHERE user='$user'"; $result5=mysql_query($sql5) or die ("SQL Error: $sql5<br>" . mysql_error()); } if($TOTALMEMBER==4){ $sql5="UPDATE winners SET points=points+'50' WHERE user='$user'"; $result5=mysql_query($sql5) or die ("SQL Error: $sql5<br>" . mysql_error()); } if($TOTALMEMBER==5){ $sql5="UPDATE winners SET points=points+'500' WHERE user='$user'"; $result5=mysql_query($sql5) or die ("SQL Error: $sql5<br>" . mysql_error()); } if($TOTALMEMBER==6){ $sql5="UPDATE winners SET points=points+'5000' WHERE user='$user'"; $result5=mysql_query($sql5) or die ("SQL Error: $sql5<br>" . mysql_error()); } ?>
  3. <? //random numbers $arr = array(); while ( count($arr) < 6 ) { $x = mt_rand(1,24); if ( !in_array($x,$arr) ) { $arr[] = $x; asort($arr); } } foreach($arr as $x){ $numbers[]=$x." "; } for($i2=0;$i2<6;$i2++){ //start cycle if($i2=="0"){ $no01=$numbers[$i2]; } if($i2=="1"){ $no02=$numbers[$i2]; } if($i2=="2"){ $no03=$numbers[$i2]; } if($i2=="3"){ $no04=$numbers[$i2]; } if($i2=="4"){ $no05=$numbers[$i2]; } if($i2=="5"){ $no06=$numbers[$i2]; } //end cycle } //connect to database $sql91="SELECT * FROM l$table WHERE draw='$draw'"; $result91=mysql_query($sql91); while($rows91=mysql_fetch_array($result91)){ $user=$rows91['user']; $show1=$rows91['no01']; $show2=$rows91['no02']; $show3=$rows91['no03']; $show4=$rows91['no04']; $show5=$rows91['no05']; $show6=$rows91['no06']; //CHECK 01 if($rows91['no01']==$no01) { $MEMBER01=1; } elseif($rows91['no02']==$no01) { $MEMBER01=1; } elseif($rows91['no03']==$no01) { $MEMBER01=1; } elseif($rows91['no04']==$no01) { $MEMBER01=1; } elseif($rows91['no05']==$no01) { $MEMBER01=1; } elseif($rows91['no06']==$no01) { $MEMBER01=1; } else { $MEMBER01=0; } //CHECK 02 if($rows91['no01'] == $no02) { $MEMBER02=1; } elseif($rows91['no02'] == $no02) { $MEMBER02=1; } elseif($rows91['no03'] == $no02) { $MEMBER02=1; } elseif($rows91['no04'] == $no02) { $MEMBER02=1; } elseif($rows91['no05'] == $no02) { $MEMBER02=1; } elseif($rows91['no06'] == $no02) { $MEMBER02=1; } else { $MEMBER02=0; } //CHECK 03 if($rows91['no01'] == $no03) { $MEMBER03=1; } elseif($rows91['no02'] == $no03) { $MEMBER03=1; } elseif($rows91['no03'] == $no03) { $MEMBER03=1; } elseif($rows91['no04'] == $no03) { $MEMBER03=1; } elseif($rows91['no05'] == $no03) { $MEMBER03=1; } elseif($rows91['no06'] == $no03) { $MEMBER03=1; } else { $MEMBER03=0; } //CHECK 04 if($rows91['no01'] == $no04) { $MEMBER04=1; } elseif($rows91['no02'] == $no04) { $MEMBER04=1; } elseif($rows91['no03'] == $no04) { $MEMBER04=1; } elseif($rows91['no04'] == $no04) { $MEMBER04=1; } elseif($rows91['no05'] == $no04) { $MEMBER04=1; } elseif($rows91['no06'] == $no04) { $MEMBER04=1; } else{ $MEMBER04=0; } //CHECK 05 if ($rows91['no01'] == $no05) { $MEMBER05=1; } elseif($rows91['no02'] == $no05) { $MEMBER05=1; } elseif($rows91['no03'] == $no05) { $MEMBER05=1; } elseif($rows91['no04'] == $no05) { $MEMBER05=1; } elseif($rows91['no05'] == $no05) { $MEMBER05=1; } elseif($rows91['no06'] == $no06) { $MEMBER05=1; } else{ $MEMBER05=0; } //CHECK 06 if ($rows91['no01'] == $no06) { $MEMBER06=1; } elseif($rows91['no02'] == $no06) { $MEMBER06=1; } elseif($rows91['no03'] == $no06) { $MEMBER06=1; } elseif($rows91['no04'] == $no06) { $MEMBER06=1; } elseif($rows91['no05'] == $no06) { $MEMBER06=1; } elseif($rows91['no06'] == $no06) { $MEMBER06=1; } else{ $MEMBER06=0; } $TOTALMEMBER=$MEMBER01+$MEMBER02+$MEMBER03+$MEMBER04+$MEMBER05+$MEMBER06; ?> Basically what I am trying to do is check all 6 numbers that are randomly generated to the already stored user numbers in a mysql database. Its DRIVING me insane as I cannot work out why it wont work or the if statements wont equal each other. The database field is set to INT for the numbers. Cheers
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.