Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:11:37+00:00 2026-06-08T10:11:37+00:00

What I am trying to do is create a contest script for a GPT

  • 0

What I am trying to do is create a contest script for a GPT site, and I want to be able to award the winners with different amounts that are defined in the database. For example first place would get what reward_1 is in the data base and so on. So I am trying to make it to where when I do mysql_query("UPDATE members SET points=points+'$reward' WHERE username='$username'") but I need $reward to be different for each of the winning users.

CLARIFICATION
When this specific script is ran it gives out the rewards to the users if the date is >= the end date of the contest (in the code it says <= because if not I wouldn’t be able to test it) but basically when it gives out the rewards I want to be able to use 1 query to do so but I want that query to give out the right rewards to the right users. For example the user who completed the most offers should get what reward_1 in the contest table says which lets say is 1000 and the second place user will get what the reward is listed as for row reward_2 like 500. The way I have it set up now it will give the same reward amount to all users instead of a different amount to each. I hope that helps!

Here is the code I have (please note that I haven’t added any functions to attempt to do this as I have no idea where to start)

UPDATE
What I am working with is what is after all of the blocked lines and the reward amounts will be coming from the dbtable contest.

I am not sure if I have given enough of a description of what I am trying to get so if I need to clarify on anything please let me know, all your help is appreciated!

Okay so I have been working on this a little bit, trying to use arrays, please excuse this sloppiness as I am only trying to possibly get things working the way I need it to! This is the new code:

<?
include_once"config.php";
date_default_timezone_set('UTC');

$query= "SELECT * FROM raffle WHERE amount>='1' ORDER BY Rand() LIMIT 2";
$result = mysql_query($query);
$raff=mysql_query("SELECT SUM(amount) FROM raffle");
$raffle=mysql_fetch_row($raff);
$amount= $raffle[0] / 2;
$dates= mysql_query("SELECT * FROM contest");
$stats= mysql_query("SELECT * FROM stats WHERE type='today'");
$statu= mysql_fetch_array($stats);

// while ($row = mysql_fetch_array($result)){
 // $uid = $row["id"]; 
 // $username = $row["user_id"];  
 // echo "User ID = $uid 
    // <br />User Name = $username 
   // <hr />"; 
// $winners= mysql_query("UPDATE members SET points=points+'".$amount."' WHERE username='".$username."'");
// $statusu1= mysql_query("UPDATE stats SET new='".$statu['new']."' WHERE type='yesterday'");
// $statusu2= mysql_query("UPDATE stats SET cashouts='".$statu['cashouts']."' WHERE type='yesterday'");
// $statusu3= mysql_query("UPDATE stats SET complete='".$statu['complete']."' WHERE type='yesterday'");
// $announce= mysql_query("INSERT INTO comment (text, home, date, text1)
// VALUES ('Rewards Cube System','',NOW(),'".$username." just won ".$amount." points in the daily raffle, Congrats!')");
 // }
 // $clear= mysql_query("UPDATE raffle SET amount='0'");
 // $clear1= mysql_query("UPDATE stats SET new='0' WHERE type='today'");
 // $clear2= mysql_query("UPDATE stats SET cashouts='0' WHERE type='today'");
 // $clear3= mysql_query("UPDATE stats SET complete='0' WHERE type='today'");
// print" DONE";



while ($dat = mysql_fetch_array($dates)) {
$places= mysql_query("SELECT * FROM members ORDER BY entries_".$dat['type']." DESC LIMIT ".$dat['rewards']."");
if ($dat['rewards'] == 1){
$reward = array ('1' => $dat['reward_1']);
}
else if ($dat['rewards'] == 2){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2']);
}
else if ($dat['rewards'] == 3){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3']);
}
else if ($dat['rewards'] == 4){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4']);
}
else if ($dat['rewards'] == 5){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4'], '5' => $dat['reward_5']);
}
else if ($dat['rewards'] == 6){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4'], '5' => $dat['reward_5'], '6' => $dat['reward_6']);
}
else if ($dat['rewards'] == 7){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4'], '5' => $dat['reward_5'], '6' => $dat['reward_6'], '7' => $dat['reward_7']);
}
else if ($dat['rewards'] == 8){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4'], '5' => $dat['reward_5'], '6' => $dat['reward_6'], '7' => $dat['reward_7'], '8' => $dat['reward_8']);
}
else if ($dat['rewards'] == 9){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4'], '5' => $dat['reward_5'], '6' => $dat['reward_6'], '7' => $dat['reward_7'], '8' => $dat['reward_8'], '9' => $dat['reward_9']);
}
else if ($dat['rewards'] == 10){
$reward = array ('1' => $dat['reward_1'], '2' => $dat['reward_2'], '3' => $dat['reward_3'], '4' => $dat['reward_4'], '5' => $dat['reward_5'], '6' => $dat['reward_6'], '7' => $dat['reward_7'], '8' => $dat['reward_8'], '9' => $dat['reward_9'], '10' => $dat['reward_10']);
}
while ($place = mysql_fetch_array($places)) {
if(time() <= strtotime($dat['date_2'])) {
foreach($reward as $rew)
print" {$dat['name']}  {$place['username']} {$rew} <br>";
}
else {
print" no contests ready for rewards given";
}
}
}
?>

It kind of gives me the results I want, but it duplicates it for each so it gives me:

Monthly Offer Contest Faiz66 2500
Monthly Offer Contest Faiz66 1000
Monthly Offer Contest Faiz66 500
Monthly Offer Contest taras 2500
Monthly Offer Contest taras 1000
Monthly Offer Contest taras 500
Monthly Offer Contest admin 2500
Monthly Offer Contest admin 1000
Monthly Offer Contest admin 500
Monthly Referral Contest taras 2500
Monthly Referral Contest taras 1000
Monthly Referral Contest taras 500
Monthly Referral Contest kira423 2500
Monthly Referral Contest kira423 1000
Monthly Referral Contest kira423 500
Monthly Referral Contest Faiz66 2500
Monthly Referral Contest Faiz66 1000
Monthly Referral Contest Faiz66 500 

Which is repeating the 3 rewards for each winner, but I need it to look like this:

Monthly Offer Contest Faiz66 2500
Monthly Offer Contest taras 1000
Monthly Offer Contest admin 500
Monthly Referral Contest taras 2500
Monthly Referral Contest kira423 1000
Monthly Referral Contest Faiz66 500 

Maybe arrays aren’t the best fix for this, but if it is, I guess I need to know how to make it look like the table above rather than the first one that it is giving me now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:11:39+00:00Added an answer on June 8, 2026 at 10:11 am

    After taking a break with this code and reading up on some other ways it could be achieved I finally came up with a working solution.

    It may not be the best, but it does work. I am open to any other solutions anyone may have!

    <?
    include_once"config.php";
    include_once"test/includes.php";
    date_default_timezone_set('America/New_York');
    
    $dates=mysql_query("SELECT * FROM contest");
    $timestamp = time();
    
    while ($dat = mysql_fetch_array($dates)) {
    $places="(SELECT * FROM `".$dat['name']."` ORDER BY `completed` DESC LIMIT ".$dat['rewards'].")";
    $results=mysql_query($places);
    
    if ($dat['rewards'] == 1){
    $reward = "".$dat['reward_1']."";
    }
    else if ($dat['rewards'] == 2){
    $reward = "".$dat['reward_1'].",".$dat['reward_2']."";
    }
    else if ($dat['rewards'] == 3){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3']."";
    }
    else if ($dat['rewards'] == 4){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4']."";
    }
    else if ($dat['rewards'] == 5){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5']."";
    }
    else if ($dat['rewards'] == 6){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6']."";
    }
    else if ($dat['rewards'] == 7){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7']."";
    }
    else if ($dat['rewards'] == 8){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7'].",".$dat['reward_8']."";
    }
    else if ($dat['rewards'] == 9){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7'].",".$dat['reward_8'].",".$dat['reward_9']."";
    }
    else if ($dat['rewards'] == 10){
    $reward = "".$dat['reward_1'].",".$dat['reward_2'].",".$dat['reward_3'].",".$dat['reward_4'].",".$dat['reward_5'].",".$dat['reward_6'].",".$dat['reward_7'].",".$dat['reward_8'].",".$dat['reward_9'].",".$dat['reward_10']."";
    }
    
    $rewardsa = explode(",", $reward);
    $i=0;
    
    // Offers Contest
    
    if(time() <= $dat['date_2'] && $dat['type'] == offer) {
    while ($place = mysql_fetch_array($results)) {
    print" {$dat['name']}  {$place['username']}  {$rewardsa[$i]}<br>";
    if($dat['r_type'] == points){
    $winners= mysql_query("UPDATE members SET points=points+'".$rewardsa[$i]."' WHERE username='".$place['username']."'") or die(mysql_error());
    $shout=mysql_query("INSERT INTO shout (id, username, datetime, shout) VALUES ('','".$shoutname."','".$timestamp."','".$place['username']." has just won ".$rewardsa[$i]." points in the ".$dat['name']."')") or die(mysql_error());
    }
    if($dat['r_type'] == cash){
    $winners= mysql_query("UPDATE members SET cash=cash+'".$rewardsa[$i]."' WHERE username='".$place['username']."'") or die(mysql_error());
    $shout=mysql_query("INSERT INTO shout (id, username, datetime, shout) VALUES ('','".$shoutname."','".$timestamp."','".$place['username']." has just won $".$rewardsa[$i]." in the ".$dat['name']."')") or die(mysql_error());
    }
    $i++;
    if($winners && $shout){
    $delete=mysql_query("DROP TABLE `".$dat['name']."`");
    }
    }
    }
    
    // Referral Contest
    
    if(time() <= $dat['date_2'] && $dat['type'] == referral) {
    while ($place = mysql_fetch_array($results)) {
    print" {$dat['name']}  {$place['username']}  {$rewardsa[$i]}<br>";
    if($dat['r_type'] == points){
    $winners= mysql_query("UPDATE members SET points=points+'".$rewardsa[$i]."' WHERE username='".$place['username']."'") or die(mysql_error());
    $shout=mysql_query("INSERT INTO shout (id, username, datetime, shout) VALUES ('','".$shoutname."','".$timestamp."','".$place['username']." has just won ".$rewardsa[$i]." points in the ".$dat['name']."')") or die(mysql_error());
    }
    if($dat['r_type'] == cash){
    $winners= mysql_query("UPDATE members SET cash=cash+'".$rewardsa[$i]."' WHERE username='".$place['username']."'") or die(mysql_error());
    $shout=mysql_query("INSERT INTO shout (id, username, datetime, shout) VALUES ('','".$shoutname."','".$timestamp."','".$place['username']." has just won $".$rewardsa[$i]." in the ".$dat['name']."')") or die(mysql_error());
    }
    $i++;
    if($winners && $shout){
    $delete=mysql_query("DROP TABLE `".$dat['name']."`");
    }
    }
    }
    
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a script that pulls an image out of the database
I'm trying to create a new launchagent file that will execute a shell script
I'm trying to create a python script that logs into JIRA using their REST
I am trying to create a script in Python that will collect data put
Hi I am trying to create a script that will count the number of
I'm trying to create a php script that will handle a mailing list for
I am trying to create a jQuery script that would remove a div/s based
I'm trying to create a simple ajax load test script that dynamically creates divs,
I'm trying to create a context menu which will be able to add extra
I'm trying to create an ascx control that can wrap content like a panel.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.