Register  |  Sign In
View unanswered posts | View active topics It is currently Sat May 10, 2025 4:45 pm



Reply to topic  [ 177 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next
 WoKJ: Box Office Game Beta - Question on Pg. 3 
Author Message
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Quick Update:

I won't be able to do any work from Atlanta, well not much. I'm going to write the database structure on my flight back, but other than that, this week will be a loss!

I will be back and doing work again from the 29th until the 6th, so hopefully I can make a big dent.

_________________
Image


Wed Dec 26, 2007 7:31 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Update:

First things first, my schedule is a bit off track. I had intended to develop a full mock before moving on to the database, and then coding, but as I went on, I moved away from this strategy.

As such, I still haven't created the visuals for how the results will look, and I won't do so until I get ready to implement that part of the game.

So what have you done?

Well, while in Atlanta, I wrote the database structure. I've already had to modify it with the work I did today, but it closes that step of the process.

I also did a LOT of work on the ability for users to submit and modify predictions. In fact, I totally finished that part today. I spent a solid 8 hours on it, but it's working, and so far as I can tell, works perfectly.

I also added a new admin section today, which allows the game's admin to add a new week for users to predict. So all in all, today was a productive day on all fronts. I was worried about manipulating dates, but ran into no problems all day. I didn't expect it, and am very happy about the progress.

So what does the prediction code do?

Here is some of the functionality added today:
- Admins can add a new week to the game.
- Users can now enter predictions.
- The system checks the date of the page load, and compares it to the prediction deadline entered by the admin. If it is past the deadline, you won't be able to enter any predictions.
- Users can edit their predictions.
- The system checks all the users input. It will force you to enter something in every category, and if you try to predict 'Movie A' twice, it will yell at you and refuse to store your prediction.

Where are we now?

Well, you can now go enter predictions. And I need you to do so!

http://www.worldofkj.com/bonanza_entry.php

I need at least 20 predictions so that I can start working on the results sections and other system functions, so please, go enter some numbers! Play around, try to break it. I can't bug test this puppy on all browsers, so I need your help.

I've tested it on Mozilla, if someone from other browsers can vouch that it works, that'd help a lot.

_________________
Image


Mon Dec 31, 2007 6:56 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Happy New Year!

NOW POST SOME PREDICTIONS! :mad:

_________________
Image


Tue Jan 01, 2008 11:08 am
Profile WWW
 
User avatar

Joined: Wed Nov 29, 2006 8:01 pm
Posts: 6385
Post Re: WoKJ: Box Office Game Beta
If movie a flops, I'll kill someone.

_________________
---!!---!!!!!!-11!!---!!---11---11!!!--!!--


Tue Jan 01, 2008 3:21 pm
Profile WWW
 
User avatar

Joined: Wed Nov 29, 2006 8:01 pm
Posts: 6385
Post Re: WoKJ: Box Office Game Beta
One quick thing. Rank doesn't matter with predictions. What I mean is, I predicted for movie b more than for movie a, yet had "b" in second rank, while "a" in first, and they stayed there after I predicted and submited.


Attachments:
Untitled-2.jpg
Untitled-2.jpg [ 51.91 KiB | Viewed 1794 times ]

_________________
---!!---!!!!!!-11!!---!!---11---11!!!--!!--
Tue Jan 01, 2008 3:25 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Yeah, I asked Corpse if she thought I should change that, or make a check for that, she said that BOM doesn't care either, and that she didn't think it mattered.

Do you think it is something I should check?

_________________
Image


Tue Jan 01, 2008 4:48 pm
Profile WWW
Artie the One-Man Party

Joined: Sat Sep 17, 2005 2:53 pm
Posts: 4632
Post Re: WoKJ: Box Office Game Beta
No, unless we want to incorporate whether or not people predicted the top ten in order correctly into our scores, which I'm pretty sure no one is interested in doing.


Tue Jan 01, 2008 4:50 pm
Profile
 
User avatar

Joined: Wed Nov 29, 2006 8:01 pm
Posts: 6385
Post Re: WoKJ: Box Office Game Beta
I meant just as a visual help when entering predictions, not to matter in actual game.

_________________
---!!---!!!!!!-11!!---!!---11---11!!!--!!--


Tue Jan 01, 2008 6:20 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Update:

OK, so per suggestion via Nebs, the prediction entry will now modify the order of your predictions based on what you put for each gross.

So whatever you give the highest gross will be #1, etc.

_________________
Image


Wed Jan 02, 2008 2:38 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
I really need more people to enter predictions. :tears:

I need 20+ so I can test the next script I have to write, and I have 3. Come on guys, it takes two seconds!

_________________
Image


Wed Jan 02, 2008 2:45 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Up to 5 predictions. Still need 15 more ... :mad:

_________________
Image


Wed Jan 02, 2008 3:10 pm
Profile WWW
Forum General
User avatar

Joined: Wed Feb 08, 2006 11:45 pm
Posts: 6447
Post Re: WoKJ: Box Office Game Beta
I had to go hunting for the link, so here it is on this page http://www.worldofkj.com/bonanza.php

_________________
......


Wed Jan 02, 2008 7:11 pm
Profile
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Update

Today was a decent day of work, but mostly with behind the scenes functionality.

What you will notice:
- I made a modification to the prediction submission so that it will re-order your movies, placing the film you have making the most money in the first position, and so on down the line.
- I made a modification so you can not predict negative amounts.

What you won't notice:
- I started work on the Admin ability to add Actuals for a given week. The functionality behind this is working now, but I still need to add on a script which updates various rankings I want to keep track of. I ran into a big issue dealing with this, and am not sure how I'm going to deal with it. I dropped Arsi and Xiayun both messages, and hopefully will hear back from them tomorrow. I also asked a few other people I thought might be able to help.

Basically, I am trying to decide if I should store everyone's weekly score in the database, or just calculate it every time someone wants to see it.

I'll make up my mind tomorrow, then get to work finishing up the script to make it work.


Where is the process:

It's hard to say really, but depending how tomorrow goes, this game could be fully functional in the coming days.

The ability to submit and edit predictions was a huge chunk of the code which needed written. That's done. The ability to add actuals, and the script that updates user's results is another huge chunk. If I am able to get it done tomorrow, then I should finish the game by Jan 6th or so.

Making the results pages is a lot of work, but nothing that's too hard, just a bit time consuming. So stay tuned, we'll see how tomorrow goes.

What I need from You
- Still looking for someone to write the How to Play section
- Keep checking the game, looking over the functionality, and reporting anything that seems odd. Try and break it, report problems. Multiple people have caught or made suggestions which have been implemented, things I wouldn't have found otherwise, so keep looking!

_________________
Image


Thu Jan 03, 2008 1:35 am
Profile WWW
Artie the One-Man Party

Joined: Sat Sep 17, 2005 2:53 pm
Posts: 4632
Post Re: WoKJ: Box Office Game Beta
Is there going to be archives listing the top players of each month/year/stuff like that?


Thu Jan 03, 2008 4:17 pm
Profile
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Update:

I just finished the script which adds actuals to the database, and updates users scores.

Everything went pretty smooth, and it's working great. The script will allow me to track the following:

- How many wins each player has
- How many weeks each player has played
- How many top tens each player has
- How many top twenties each player has
- Average score for each player

I hope to write another script in the future which will also allow me to track:

- How many monthly wins each player has
- How many monthly top tens each player has
- How many monthly top twenties each player has
- How many yearly wins each player has
- How many yearly top tens each player has
- How many yearly top twenties each player has

While most of this is behind the scenes, it was a HUGE chunk of the game. All I have left is to display results!

So you can get an idea, here is the code written today:

Code:
<?php
   // Returns the average of 10 scores
   function get_average($movie_1_score, $movie_2_score, $movie_3_score, $movie_4_score, $movie_5_score, $movie_6_score, $movie_7_score, $movie_8_score, $movie_9_score, $movie_10_score) {
      $total = $movie_1_score + $movie_2_score + $movie_3_score + $movie_4_score + $movie_5_score + $movie_6_score + $movie_7_score + $movie_8_score + $movie_9_score + $movie_10_score;
      $average = $total / 10;
      $average = round($average, 3);
      return $average;
   }
   
   // Returns the score of the movie with the same name
   function calculate_score($user_movie_name, $user_predicted_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross) {
      if ($user_movie_name == $movie_1_name) {
         $difference = $user_predicted_gross - $movie_1_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_1_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_2_name) {
         $difference = $user_predicted_gross - $movie_2_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_2_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_3_name) {
         $difference = $user_predicted_gross - $movie_3_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_3_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_4_name) {
         $difference = $user_predicted_gross - $movie_4_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_4_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_5_name) {
         $difference = $user_predicted_gross - $movie_5_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_5_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_6_name) {
         $difference = $user_predicted_gross - $movie_6_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_6_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_7_name) {
         $difference = $user_predicted_gross - $movie_7_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_7_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_8_name) {
         $difference = $user_predicted_gross - $movie_8_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_8_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_9_name) {
         $difference = $user_predicted_gross - $movie_9_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_9_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
      else if ($user_movie_name == $movie_10_name) {
         $difference = $user_predicted_gross - $movie_10_gross;
         $absolute = abs($difference);
         $score_unformated = $absolute / $movie_10_gross;
         $score = 1 - $score_unformated;
         $score = $score * 100;
         $score = round($score, 3);
         if ($score < 0) {
            $score = 0;
         }
         return $score;
      }
   }
   
   $week_id = $_POST['week_id'];
   
   $movie_1_gross = $_POST['movie_1_gross'];
   $movie_2_gross = $_POST['movie_2_gross'];
   $movie_3_gross = $_POST['movie_3_gross'];
   $movie_4_gross = $_POST['movie_4_gross'];
   $movie_5_gross = $_POST['movie_5_gross'];
   $movie_6_gross = $_POST['movie_6_gross'];
   $movie_7_gross = $_POST['movie_7_gross'];
   $movie_8_gross = $_POST['movie_8_gross'];
   $movie_9_gross = $_POST['movie_9_gross'];
   $movie_10_gross = $_POST['movie_10_gross'];
   
   $movie_1_name = $_POST['movie_1_name'];
   $movie_2_name = $_POST['movie_2_name'];
   $movie_3_name = $_POST['movie_3_name'];
   $movie_4_name = $_POST['movie_4_name'];
   $movie_5_name = $_POST['movie_5_name'];
   $movie_6_name = $_POST['movie_6_name'];
   $movie_7_name = $_POST['movie_7_name'];
   $movie_8_name = $_POST['movie_8_name'];
   $movie_9_name = $_POST['movie_9_name'];
   $movie_10_name = $_POST['movie_10_name'];
   
   $databaseConnect = mysqli_connect("localhost", "user", "pass", "db")
         Or die("Unable to connect to the database.");
            
   $query = "INSERT INTO bonanza_actuals VALUES ($week_id, '$movie_1_name', $movie_1_gross, '$movie_2_name', $movie_2_gross, '$movie_3_name', $movie_3_gross, '$movie_4_name', $movie_4_gross, '$movie_5_name', $movie_5_gross, '$movie_6_name', $movie_6_gross, '$movie_7_name', $movie_7_gross, '$movie_8_name', $movie_8_gross, '$movie_9_name', $movie_9_gross, '$movie_10_name', $movie_10_gross)";
   
   if (mysqli_query($databaseConnect, $query)) {
      echo "Actuals stored in database ... <br />Now updating rankings ...<br /><br />";
      
      $query = "SELECT * FROM bonanza_predictions WHERE week_id = $week_id";
      $result = mysqli_query($databaseConnect, $query);
      
      if (mysqli_num_rows($result) == 0) {
         echo "Error pulling predictions from database.";
      }
      else {
         $scores_array = array();
         
         $row = mysqli_fetch_assoc($result);
         while ($row) {
            $user_id = $row['user_id'];
            $prediction_id = $row['prediction_id'];
         
            $movie_1_user_gross = $row['movie_1_gross'];
            $movie_2_user_gross = $row['movie_2_gross'];
            $movie_3_user_gross = $row['movie_3_gross'];
            $movie_4_user_gross = $row['movie_4_gross'];
            $movie_5_user_gross = $row['movie_5_gross'];
            $movie_6_user_gross = $row['movie_6_gross'];
            $movie_7_user_gross = $row['movie_7_gross'];
            $movie_8_user_gross = $row['movie_8_gross'];
            $movie_9_user_gross = $row['movie_9_gross'];
            $movie_10_user_gross = $row['movie_10_gross'];
            
            $movie_1_user_name = $row['movie_1_name'];
            $movie_2_user_name = $row['movie_2_name'];
            $movie_3_user_name = $row['movie_3_name'];
            $movie_4_user_name = $row['movie_4_name'];
            $movie_5_user_name = $row['movie_5_name'];
            $movie_6_user_name = $row['movie_6_name'];
            $movie_7_user_name = $row['movie_7_name'];
            $movie_8_user_name = $row['movie_8_name'];
            $movie_9_user_name = $row['movie_9_name'];
            $movie_10_user_name = $row['movie_10_name'];
            
            $movie_1_score = calculate_score($movie_1_user_name, $movie_1_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_2_score = calculate_score($movie_2_user_name, $movie_2_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_3_score = calculate_score($movie_3_user_name, $movie_3_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_4_score = calculate_score($movie_4_user_name, $movie_4_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_5_score = calculate_score($movie_5_user_name, $movie_5_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_6_score = calculate_score($movie_6_user_name, $movie_6_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_7_score = calculate_score($movie_7_user_name, $movie_7_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_8_score = calculate_score($movie_8_user_name, $movie_8_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_9_score = calculate_score($movie_9_user_name, $movie_9_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $movie_10_score = calculate_score($movie_10_user_name, $movie_10_user_gross, $movie_1_name, $movie_1_gross, $movie_2_name, $movie_2_gross, $movie_3_name, $movie_3_gross, $movie_4_name, $movie_4_gross, $movie_5_name, $movie_5_gross, $movie_6_name, $movie_6_gross, $movie_7_name, $movie_7_gross, $movie_8_name, $movie_8_gross, $movie_9_name, $movie_9_gross, $movie_10_name, $movie_10_gross);
            
            $average = get_average($movie_1_score, $movie_2_score, $movie_3_score, $movie_4_score, $movie_5_score, $movie_6_score, $movie_7_score, $movie_8_score, $movie_9_score, $movie_10_score);
            
            $query_2 = "UPDATE bonanza_predictions SET score = $average WHERE prediction_id = $prediction_id";
            
            if (mysqli_query($databaseConnect, $query_2)) {
               $scores_array['' . $user_id . ''] = $average;
            }
            else {
               echo "Error updating user " . $user_id . "'s score ... <br />";
               mysqli_close($databaseConnect);
               exit;
            }
            
            $row = mysqli_fetch_assoc($result);
         }
         echo "User's scores updated ... <br /><br />";
         mysqli_free_result($result);
         asort($scores_array, SORT_NUMERIC);
         
         $rank = count($scores_array);
         foreach ($scores_array as $user_id => $score) {
            // Update ranking for the winner
            if ($rank == 1) {
               $query = "SELECT average_score, week_played FROM bonanza_rankings WHERE user_id = $user_id";
               $result = mysqli_query($databaseConnect, $query);
               
               if (mysqli_num_rows($result) == 0) {
                  mysqli_free_result($result);
                  
                  $query = "INSERT INTO bonanza_rankings VALUES ($user_id, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, $score)";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
               else {
                  $row = mysqli_fetch_assoc($result);
                  $average_score = $row['average_score'];
                  $week_played = $row['week_played'];
                  mysqli_free_result($result);
                  
                  $total_score = $average_score * $week_played;
                  $new_total_score = $total_score + $score;
                  $new_week_played = $week_played + 1;
                  $new_average_score = $new_total_score / $new_week_played;
                  $new_average_score = round($new_average_score, 3);
                  
                  $query = "UPDATE bonanza_rankings SET week_wins = week_wins +1, week_top_ten = week_top_ten + 1, week_top_twenty = week_top_twenty + 1, week_played = $new_week_played, average_score = $new_average_score WHERE user_id = $user_id";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
            }
            // Update rankings for people ranked 2-10
            else if ($rank <= 10) {
               $query = "SELECT average_score, week_played FROM bonanza_rankings WHERE user_id = $user_id";
               $result = mysqli_query($databaseConnect, $query);
               
               if (mysqli_num_rows($result) == 0) {
                  mysqli_free_result($result);
                  
                  $query = "INSERT INTO bonanza_rankings VALUES ($user_id, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, $score)";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
               else {
                  $row = mysqli_fetch_assoc($result);
                  $average_score = $row['average_score'];
                  $week_played = $row['week_played'];
                  mysqli_free_result($result);
                  
                  $total_score = $average_score * $week_played;
                  $new_total_score = $total_score + $score;
                  $new_week_played = $week_played + 1;
                  $new_average_score = $new_total_score / $new_week_played;
                  $new_average_score = round($new_average_score, 3);
                  
                  $query = "UPDATE bonanza_rankings SET week_top_ten = week_top_ten + 1, week_top_twenty = week_top_twenty + 1, week_played = $new_week_played, average_score = $new_average_score WHERE user_id = $user_id";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
            }
            // Update rankings for people ranked 11-20
            else if ($rank <= 20) {
               $query = "SELECT average_score, week_played FROM bonanza_rankings WHERE user_id = $user_id";
               $result = mysqli_query($databaseConnect, $query);
               
               if (mysqli_num_rows($result) == 0) {
                  mysqli_free_result($result);
                  
                  $query = "INSERT INTO bonanza_rankings VALUES ($user_id, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, $score)";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
               else {
                  $row = mysqli_fetch_assoc($result);
                  $average_score = $row['average_score'];
                  $week_played = $row['week_played'];
                  mysqli_free_result($result);
                  
                  $total_score = $average_score * $week_played;
                  $new_total_score = $total_score + $score;
                  $new_week_played = $week_played + 1;
                  $new_average_score = $new_total_score / $new_week_played;
                  $new_average_score = round($new_average_score, 3);
                  
                  $query = "UPDATE bonanza_rankings SET week_top_twenty = week_top_twenty + 1, week_played = $new_week_played, average_score = $new_average_score WHERE user_id = $user_id";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
            }
            // Update rankings for everyone else
            else {
               $query = "SELECT average_score, week_played FROM bonanza_rankings WHERE user_id = $user_id";
               $result = mysqli_query($databaseConnect, $query);
               
               if (mysqli_num_rows($result) == 0) {
                  mysqli_free_result($result);
                  
                  $query = "INSERT INTO bonanza_rankings VALUES ($user_id, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, $score)";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
               else {
                  $row = mysqli_fetch_assoc($result);
                  $average_score = $row['average_score'];
                  $week_played = $row['week_played'];
                  mysqli_free_result($result);
                  
                  $total_score = $average_score * $week_played;
                  $new_total_score = $total_score + $score;
                  $new_week_played = $week_played + 1;
                  $new_average_score = $new_total_score / $new_week_played;
                  $new_average_score = round($new_average_score, 3);
                  
                  $query = "UPDATE bonanza_rankings SET week_played = $new_week_played, average_score = $new_average_score WHERE user_id = $user_id";
                  
                  if (mysqli_query($databaseConnect, $query)) {
                  }
                  else {
                     echo "Error updating user " . $user_id . "'s rankings.";
                     mysqli_close($databaseConnect);
                     exit;
                  }
               }
            }
            $rank--;
         }
         echo "Rankings properly incremented ... <br /><br />";
         echo "Successful Update.";
      }
   }
   else {
      echo "Error adding actuals to database.";
   }
   
   mysqli_close($databaseConnect);
   ?>

_________________
Image


Thu Jan 03, 2008 4:20 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
french man wrote:
Is there going to be archives listing the top players of each month/year/stuff like that?


Yes, this is the next step in the process. Right now, all the data is stored, I just have to create the code to pull it and display it.

_________________
Image


Thu Jan 03, 2008 4:22 pm
Profile WWW
 
User avatar

Joined: Wed Nov 29, 2006 8:01 pm
Posts: 6385
Post Re: WoKJ: Box Office Game Beta
Excellent work, Eagle.

_________________
---!!---!!!!!!-11!!---!!---11---11!!!--!!--


Thu Jan 03, 2008 4:22 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Nebs wrote:
Excellent work, Eagle.


I know! I'm excited. :hahaha:

The hardest work is all behind me, it's only a matter of time now. :twisted:

_________________
Image


Thu Jan 03, 2008 4:25 pm
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Update:

Made a modification to the front landing page so it now pulls the actual score you had last week. Still have to modify it to deal with people without a score.

Edit: Now show's NA if you have nothing.

_________________
Image


Thu Jan 03, 2008 6:51 pm
Profile WWW
Don't Dream It, Be It
User avatar

Joined: Wed Aug 02, 2006 12:45 pm
Posts: 37162
Location: The Graveyard
Post Re: WoKJ: Box Office Game Beta
http://www.worldofkj.com/bonanza_results.php

Does anybody see ANY yellow on this page? Other than the Google ads?

_________________
Japan Box Office

“Gods are great ... but the heart is greater. For it is from our hearts they come, and to our hearts they shall return.”
“We were like gods at the dawning of the world, & our joy was so bright we could see nothing else but the other.”
“There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.”
“You have to pretend you get an endgame. You have to carry on like you will; otherwise, you can't carry on at all.”
"Paper is dead without words / Ink idle without a poem / All the world dead without stories."


Fri Jan 04, 2008 1:02 am
Profile WWW
KJ's Leading Pundit
User avatar

Joined: Tue Oct 12, 2004 4:45 pm
Posts: 63026
Location: Tonight... YOU!
Post Re: WoKJ: Box Office Game Beta
Corpse wrote:
http://www.worldofkj.com/bonanza_results.php

Does anybody see ANY yellow on this page? Other than the Google ads?


The "O" in WOKJ?

The dots in front of the links on the left?

Or are those orange?

_________________
trixster wrote:
shut the fuck up zwackerm, you're out of your fucking element

trixster wrote:
chippy is correct

Rev wrote:
Fuck Trump


Fri Jan 04, 2008 1:11 am
Profile
Don't Dream It, Be It
User avatar

Joined: Wed Aug 02, 2006 12:45 pm
Posts: 37162
Location: The Graveyard
Post Re: WoKJ: Box Office Game Beta
Munkatouille wrote:
Corpse wrote:
http://www.worldofkj.com/bonanza_results.php

Does anybody see ANY yellow on this page? Other than the Google ads?


The "O" in WOKJ?

The dots in front of the links on the left?

Or are those orange?



Uhm, Eagle? :whistle:

_________________
Japan Box Office

“Gods are great ... but the heart is greater. For it is from our hearts they come, and to our hearts they shall return.”
“We were like gods at the dawning of the world, & our joy was so bright we could see nothing else but the other.”
“There are three things all wise men fear: the sea in storm, a night with no moon, and the anger of a gentle man.”
“You have to pretend you get an endgame. You have to carry on like you will; otherwise, you can't carry on at all.”
"Paper is dead without words / Ink idle without a poem / All the world dead without stories."


Fri Jan 04, 2008 1:14 am
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
You're all crazy.

First of all, I have made a mock for the "My Results" page. It's not functional, but will be tomorrow early afternoon.

Second of all, there is yellow:

Image

_________________
Image


Fri Jan 04, 2008 1:21 am
Profile WWW
Site Owner
User avatar

Joined: Wed Sep 15, 2004 1:09 pm
Posts: 14631
Location: Pittsburgh
Post Re: WoKJ: Box Office Game Beta
Update:

http://www.worldofkj.com/bonanza_results.php

The 'My Results' tab is now functional and working.

I have decided to 'launch' the game starting Monday. So you will be able to enter predictions for next weekend, and your scores will be calculated etc.

This will be the first week, and unless some unforeseen problem compromises the scores, it will count as the first week of the year, and will be recorded for ever and ever, amen. Please help spread the word.

_________________
Image


Fri Jan 04, 2008 4:30 pm
Profile WWW
Teh Mexican
User avatar

Joined: Fri Oct 15, 2004 11:56 pm
Posts: 26066
Location: In good ol' Mexico
Post Re: WoKJ: Box Office Game Beta - Game Starts This Week!
Awesome! : :D

Great work Eagle.


Fri Jan 04, 2008 4:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 177 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 8  Next

Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.