Jump to content

carrying an amount to the next code stage


nclemale

Recommended Posts

hi guys .

 

been messing around with some codes and am trying to make a small code for my site so when they click on play it deducts site points off them and inserts it into a hourly jackpot that is won randomly .first off is i cant manage to carry the jackpot to the winning user .at present i have it set at 1000 points which works fine .

this is the code that when they clck play

$lot = mysql_fetch_array(mysql_query("SELECT jackpot FROM lotto "));
    $res=mysql_query("UPDATE lotto SET jackpot='".($lot[0]+50)."'");
    $res=mysql_query("UPDATE users SET lotto='1' WHERE id='".$uid."'");
  $ugpl = mysql_fetch_array(mysql_query("SELECT plusses FROM users WHERE id='".$uid."'"));
  $ugpl = $ugpl[0] - 50;
  mysql_query("UPDATE users SET plusses='".$ugpl."' WHERE id='".$uid."'");
if($res){
  echo "<img src=\"../images/ok.gif\" alt=\"o\"/>Entered lotto successfully<br/>";
}else{
  echo "<img src=\"../images/notok.gif\" alt=\"x\"/>Error<br/>";
  } 

and this is the winning code for when a user is chosen .

$rpgd = mysql_query("SELECT id, lotto FROM users ORDER by lotto DESC LIMIT 1");
while($rpgds=mysql_fetch_array($rpgd))
{
$winner =$rpgds[0];
$winner2 =$rpgds[1];
}
$unick2 = getnick_uid($winner);
mysql_query("UPDATE users SET plusses=plusses+'1000' WHERE id='".$winner."'");
mysql_query("UPDATE users SET lotto='0'");
mysql_query("UPDATE lotto SET jackpot='0'");
echo"$unick2 has won the jackpot "; 

as you can see the line that has plusses=plusses+'1000' is the part i need to get right.

 

once i have this sorted i will need help with the time part of it.

thanks

ok after trying a few more things i finally sussed it so it carries the jackpot to the user that wins . all i did is this

 

$jack = mysql_fetch_array(mysql_query("SELECT jackpot FROM lotto "));
mysql_query("UPDATE users SET plusses=plusses+'$jack[0]' WHERE id='".$winner."'");

simple yes but i am just learning.

 

ok is there a way i can add time coding in this so lets say it all gets reset every hour and it randomly picks a winner on its own. ??

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.