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

Link to comment
Share on other sites

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. ??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

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.