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
https://forums.phpfreaks.com/topic/92738-need-a-suggestion-and-some-help/
Share on other sites

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.