Jump to content

Need a Suggestion, and Some help.


Lamez

Recommended Posts

I am making a point system, for my bracket website.

 

I want be able to select the winner, I have that, It adds it to a table in the db.

But after I select the winners I want it to run the points php file for ever user.

 

Will I have to do a loop?

 

Also, will you guys look over my code, it is not running properly. It is suppose to check if TeamA is equal to TeamPicked, if so add points, then add the value to the DB, if not go on to the next If statement.

 

It does add points if the values are the same, but it they are not, then it does not add the points for the if statement after that.  It also does not update to the DB.

 

<?php
include("style/include/session.php");
include ("style/include/cons/head.php");
echo '<div class="box">';
if($session->logged_in){
$user = $session->username;

   /*Pull Winners for Round 1*/
  $q = mysql_query("Select * from `rnd1_win`");
  $win=mysql_fetch_array($q);
   
  /*Pull User Picks for Round 1*/
  $q = mysql_query("Select * from `rnd1`");
  $pick=mysql_fetch_array($q);
  
  /*Pull Point Values for Round 1*/
  $q = mysql_query("Select * from `points`");
  $point=mysql_fetch_array($q);
  $value = $point['0'];
  
  /*Pull User Points for Round 1*/
  $q = mysql_query("Select * from `userpoints`");
  $usrpoint=mysql_fetch_array($q);
  $total = $usrpoint['total'];
  $rnd1 = $usrpoint['1'];
  
  
  
  if ($win['0'] === ($pick['a1'])){
   $total = $value + $total;
   $rnd1 = $value + $rnd1;
   $q = "UPDATE `userpoints` SET `total`=$total WHERE `username`='$user'";
       mysql_query($q);
   $q = "UPDATE `userpoints` SET `1`=$rnd1 WHERE `username`='$user'";
       mysql_query($q);
   }else{
   
  if ($win['1'] === ($pick['a2'])){
   $total = $value + $total;
   $rnd1 = $value + $rnd1;
   $q = "UPDATE `userpoints` SET `total`=$total WHERE `username`='$user'";
       mysql_query($q);
   $q = "UPDATE `userpoints` SET `2`=$rnd1 WHERE `username`='$user'";
       mysql_query($q);
   }
   
   
   echo "<h2>Point Test</h2>";
   echo "<p>Your Total: $total<br>";
   echo "Your Round 1: $rnd1</p>";
  }
  
}else{
include ("style/include/cons/member.php");
}
print '</div>';
include ("style/include/cons/foot.php");
  
?>

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.