Jump to content
MakeWebGames

Reduce this?


newttster

Recommended Posts

Okay ... so I've managed to create a bingo game for my game. The problem I am having is trying to reduce the number of queries being done.

For each variation it has to check upwards to 55 numbers and compare them against a base of 25 numbers. You can see based on that the length of code that is involved by the way I have done this. I am sure there is a shorter way of doing this, if anyone has any ideas. I am just including one snippet of it for you to see. This is just comparing the first number of the base 25.

It works fine the way it is now. No errors. Displays the way it should etc. I just know there is a way to reduce the code and queries ... I just can't figure it out.

I would like to put this out there as a free mod ... posting all of that code would take hours. *laughs* Thanks in advance for your ideas and suggestions.

Here's the snippet;

if ($m['number1']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number2']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number3']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number4']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number5']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number6']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number7']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number8']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>";  
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number9']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number10']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number11']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number12']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number13']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number14']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number15']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number16']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number17']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number18']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number19']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number20']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number21']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number22']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number23']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number24']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number25']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number26']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number27']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number28']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number29']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
elseif ($m['number30']==$t['bingob1']) {
echo"<tr height=50><td width=200><center><font size=3 color=darkred>{$t['bingob1']}</font></center></td>"; 
$db->query("UPDATE bingothree SET bingob1=1 WHERE userid={$ir['userid']}"); }
else {
echo"<tr height=50><td width=200><center><font size=3>{$t['bingob1']}</font></center></td>"; }
Link to comment
Share on other sites

Such as? I've looked at comparison type functions, obviously I am missing something because none seem to fit the bill.

Perhaps a little more explanation;

1. A shuffle of 75 numbers is done and the base 25 is pulled.

2. A second shuffle of 75 numbers is done.

3. For the first comparison ... it takes 30 numbers from the second shuffle and compares each of those 30 against the base 25 of the first shuffle.

Link to comment
Share on other sites

if (in_array($t['bingob1'], $m)) {
   $db->query('UPDATE bingothree SET bingbob1=1 WHERE userid = ?', array($ir['userid']));
   echo '<tr height=50><td width=200><center><font size=3 color=darkred>' . $t['bingob1'] . '</font></center></td>';
} else {
   echo '<tr height=50><td width=200><center><font size=3>' . $t['bingob1'] . '</font></center></td>';
}

 

Ref: http://php.net/manual/en/function.in-array.php

Edited by Spudinski
Link to comment
Share on other sites

Thank you, Spudinski. Sorry for the delay in responding to this. This works wonderfully. I do have a question though.

With the shuffle of the second set of numbers ... I actually only use 55 of them.

The way it works is this ... the first compare is 30 numbers, then the next 5, then the next five and so on until all 55 numbers have been compared. These 55 numbers stay constant throughout all the compares being done.

It's like in a real life bingo where the numbers are called and compared.

My question is this ... is there a way to just compare the first 30 numbers pulled. Then in the next compare adding the next 5 numbers giving 35 to compare and so on?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...