Jump to content

karimali831

Members
  • Posts

    436
  • Joined

  • Last visited

Posts posted by karimali831

  1. Hi all,

     

    I'm trying to use this login script but I keep getting server error,

    I have noticed the server error is because of this if() statement:-

     

    Any thoughts please?

    if ($stmt = $mysqli->prepare("SELECT id, username, password, salt FROM members WHERE email = ? LIMIT 1")) {

     

     

     
    
        function login($email, $password, $db) {
            // Using prepared Statements means that SQL injection is not possible. 
            if ($stmt = $mysqli->prepare("SELECT id, username, password, salt FROM members WHERE email = ? LIMIT 1")) {
               $stmt->bind_param('s', $email); // Bind "$email" to parameter.
               $stmt->execute(); // Execute the prepared query.
               $stmt->store_result();
               $stmt->bind_result($user_id, $username, $db_password, $salt); // get variables from result.
               $stmt->fetch();
               $password = hash('sha512', $password.$salt); // hash the password with the unique salt.
          
               if($stmt->num_rows == 1) { // If the user exists
                  // We check if the account is locked from too many login attempts
                  if(checkbrute($user_id, $db) == true) { 
                     // Account is locked
                     // Send an email to user saying their account is locked
                     //return false;
      return "Account locked";
                  } else {
                  
       if($db_password == $password) { // Check if the password in the database matches the password the user submitted. 
                     // Password is correct!
     
                        $user_browser = $_SERVER['HTTP_USER_AGENT']; // Get the user-agent string of the user.
                        $user_id = preg_replace("/[^0-9]+/", "", $user_id); // XSS protection as we might print this value
                        $_SESSION['user_id'] = $user_id; 
                        $username = preg_replace("/[^a-zA-Z0-9_\-]+/", "", $username); // XSS protection as we might print this value
                        $_SESSION['username'] = $username;
                        $_SESSION['login_string'] = hash('sha512', $password.$user_browser);
                        // Login successful.
                        //return true;    
     
    return "Login successful";
                    
    } else {
     
                        // Password is not correct
                        // We record this attempt in the database
                        $now = time();
                        $db->query("INSERT INTO login_attempts (user_id, time) VALUES ('$user_id', '$now')");
                        //return false;
    return "Password incorrect";
                    }
                  }
               } else {
                  // No user exists. 
                  //return false;
     return "User does not exist";
               }
            }
        }
    
    
    
  2. Thanks both,

     

    One of the ways it inserts is this code:-

     

    
    $clans=safe_query("SELECT clanID FROM ".PREFIX."cup_clans WHERE cupID='$cupID' && checkin='1'");
    while($dv=mysql_fetch_array($clans)) {
    if($n < 1)
    $n=1;
    $clan[$n] = $dv['clanID'];
    $n++;
    }
    $count = count($clan);
    
    while($count < $max){
    $count++;
    $clan[$count] = 2147483647;
    }
    
    shuffle($clan);
    
    $i2=0;
    for ($i = 1; $i <= $max; $i++) {
    if($clan[$i2] || $clan[$i2+1])
    safe_query("INSERT INTO ".PREFIX."cup_matches (cupID, ladID, matchno, date, clan1, clan2, score1, score2, server, hltv, report, comment, type) VALUES ('$cupID', '0', '$i', '".time()."', '".$clan[$i2]."', '".$clan[$i2+1]."', '', '', '', '', '', '2', 'cup')");
    $i2 += 2;
    }
    

     

    And when I try running the below query I receive #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS t1 JOIN ( SELECT cupID, matchno, MIN(date) AS mindate FROM ws' at line 1

     

    I can't understand this query sorry.

     

    DELETE FROM ws_B3T_cup_matches AS t1

    JOIN (

    SELECT cupID, matchno, MIN(date) AS mindate

    FROM ws_B3T_cup_matches

    GROUP BY cupID, matchno

    HAVING COUNT(1) > 1

    ) AS t2 ON t1.cupID = t2.cupID AND t1.matchno = t2.matchno AND t1.date > t2.mindate

  3. Hi all,

     

    This is a rare occurrence I get duplicated rows but it can happen for some reason which leads to big problems.

    Not sure how they are duplicating so I would rather just get the other row(s) deleted.

     

    cupID and matchno columns should be always be unique, when I set this in phpmyadmin it will be return as there is a duplicate.

    So I am looking for a script to delete duplicates then I can set as unique.

     

    Here is example: the row(s) to be deleted is the latest, so the row not to be deleted is the first insert.

    helppr.png

     

    Anyone help me with this please?

     

    Many thanks.

  4. Hi all,

     

    I am trying to send mail to multiple recipients using array, I am using two while loops to store values in $to array variable.

     

    $to[]=$to_email1['email'];

    $to[]=$to_email2['email'];

     

    there is two values stored in

    $to[]=$to_email1['email'];

     

    and one value stored in

    $to[]=$to_email2['email'];

     

    the below code only sends 2 emails when it is suppose to send 3?

    it does not send to the next value of $to[]=$to_email1['email']; so I assume

    it will only send to first every time?

     

    I have noticed when I start n=1; it gets only the email it does not send to when n=0;

    So I need the for loop to get all possible values.

     

    any help please I'd be thankful. sorry if unclear!

     

    
    
    <?php
    $query = safe_query("SELECT * FROM ".PREFIX."cup_clan_members WHERE clanID='$challenger_ma'");
    while($to_ds3 = mysql_fetch_array($query)) {
    
    $to_email1=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."user WHERE userID='".$to_ds3['userID']."'"));
    
    if(isleader($to_ds3['userID'],$challenger_ma)) {
    
    echo $to_email1['email'].'<br>';
    
    $to[]=$to_email1['email'];
    $ni[]=$to_email1['nickname'];
    }
    }
    
    $query = safe_query("SELECT * FROM ".PREFIX."cup_clan_members WHERE clanID='$challenged_ma'");
    while($to_ds4 = mysql_fetch_array($query)) {
    
    $to_email2=mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."user WHERE userID='".$to_ds4['userID']."'"));
    
    if(isleader($to_ds4['userID'],$challenged_ma)) {
    $to[]=$to_email2['email'];
    $ni[]=$to_email2['nickname'];
    }
    }
    
    $n=0;
    for ($n=0; isset($to[$n]) && isset($ni[$n]); $n++) {
    
    echo $to[$n].'<br>';
    
    // subject
    $subject = 'Ladder Challenge Notification';
    
    // message
    $message = '
    <html>
    <head>
    <title>Ladder Challenge Notification</title>
    </head>
    <body>
    Hello '.$ni[$n].'
    </body>
    </html>
    ';
    
    // To send HTML mail, the Content-type header must be set
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: '.$ni[$n].' <'.$to[$n].'>' . "\r\n";
    $headers .= 'From: '.$dt['title'].' <'.$sender_from.'>' . "\r\n";
    $headers .= 'Cc: '.$sender_from . "\r\n";
    
    // Mail it
    
    mail($to[$n], $subject, $message, $headers);
    $n++;
    }
    ?>
    

  5. Sorry for not understanding.

     

    I am looking at the structure of the database, all having int(11) data types.

     

    ID column which is the auto increment

    cupID column

    ladID column

    clanID column

    userID column

     

    I just want to insert values for ladID, clanID and userID.

    There is definitely not a duplicate entry for the values..

  6. Hey,

     

    I can't understand this query failed, it says duplicate entry 0-1-1 which is in the database

    but I am trying to insert 3-1-1, there is no record for this so why won't it insert?

     

     

    error=Duplicate entry '0-1-1' for key 2

    query=INSERT INTO ws_bi2_cup_clan_lineup (ladID, clanID, userID) VALUES ('3', '1', '1')

     

    Thanks for any help

  7. Hi,

     

    I have a basic group league setup for 16 signups, 8 registers in group A and other 8 in group B and use two unions in my query to generate all combinations (all vs. all) which means it will always be 16 / 2 (A and B) * 7 weeks = 56 matches.  (28 matches for group A and 28 for group B) each competitor will have 7 matches each and I am trying to split these matches in separate tables and just haven't got a clue to how or where to start?

     

    There should be 7 tables showing 4 matches each per group.

     

    Query:-

                       safe_query("INSERT INTO ".PREFIX."cup_matches ($type, $type_opp, matchno, clan1, clan2, comment, 1on1) 
                       (SELECT a.$type,
                              a.$type_opp,
                              a.matchno,
                              a.clan1,
                              b.clan2 AS 'versus',
                              a.comment,
                              a.1on1
                       FROM ".PREFIX."cup_matches a
                            JOIN ws_bi2_cup_matches b ON a.$type = b.$type AND b.$type = '$let_alpha' 
                                                               AND b.matchno = '$ID' 
                                                               AND a.clan2 != b.clan2				
                                                               AND b.type = 'gs'
                       WHERE a.matchno = '$ID'
                         AND a.type = 'gs')
                       UNION
                       (SELECT a.$type,
                              a.$type_opp,
                              a.matchno,
                              a.clan1,
                              b.clan1 AS 'versus',
                              a.comment,
                              a.1on1
                       FROM ".PREFIX."cup_matches a
                            JOIN ws_bi2_cup_matches b ON a.$type = b.$type AND b.$type = '$let_alpha' 
                                                               AND b.matchno = '$ID' 
                                                               AND a.clan1 < b.clan1 
                                                               AND b.type = 'gs'
                       WHERE a.matchno = '$ID'
                         AND a.type = 'gs')		     
                       UNION
                       (SELECT a.$type,
                              a.$type_opp,
                              a.matchno,
                              a.clan2,
                              b.clan2 AS 'versus',
                              a.comment,
                              a.1on1
                       FROM ".PREFIX."cup_matches a
                            JOIN ws_bi2_cup_matches b ON a.$type = b.$type AND b.$type = '$let_alpha' 
                                                               AND b.matchno = '$ID' 
                                                               AND a.clan2 < b.clan2 
                                                               AND b.type = 'gs'
                       WHERE a.matchno = '$ID'
                         AND a.type = 'gs')	   
                       ORDER BY clan1 DESC, versus");
    

     

    Table:

    http://s13.postimage.org/48mcpf1dx/solved.png

    solved.png

     

    Anyone understand what I am trying to do?

     

    Thanks for any help.

  8. Thanks for your help, should of explained I am trying to do this for the lower/loser bracket,

    so the loser in upper bracket drops down to lower bracket.

     

    If you take a look here:-

    http://teamx1.com/popup.php?site=test&action=brackets

     

    You will notice the upper bracket is fine but the lower bracket is not

    and should have the structure of

     

    http://teamx1.com/lbracket8.html

    http://teamx1.com/lbracket.html

     

    Upper bracket is more straightforward but lower bracket I am having problems.

     

    Hope you can help me on this.

     

  9. Hi all,

     

    Would anyone be able to point me in the right direction in using php to create html tables, for instance this is a lower bracket for a 8/16 tournament-tree and trying to find a way to use php to create this table for 32+ brackets.

     

    This is 8:-

    http://teamx1.com/lbracket8.html

     

    
    <table align="center" cellpadding="2" cellspacing="0" width="100%">
    	<tr>
            <td> </td>			
            <td> </td>			
            <td> </td>			
            <td> </td>			
            <td> </td>		
        </tr>	
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan27">$clan[27]</select></td>
            <td> </td>
        </tr>	  
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>		  
        <tr>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan21">$clan[21]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>       
    		<td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[11]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan25">$clan[25]</select></td>
            <td style="border-right:2px solid #000000;" align="center">$match[14]</td>
            <td bgcolor="#efefef" align="center"><select name="lb_winner" onChange="change_clan(this.value, 'clan16')">$clan[lb_winner]</select></td>
        </tr>	  
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan17">$clan[17]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td style="border-right:2px solid #000000;" align="center">$match[9]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan22">$clan[22]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan18">$clan[18]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[13]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan28">$clan[28]</select></td>
            <td> </td>
        </tr>	  
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan19">$clan[19]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td style="border-right:2px solid #000000;" align="center">$match[10]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan23">$clan[23]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan20">$clan[20]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[12]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan26">$clan[26]</select></td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
    		<td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
    		<td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan24">$clan[24]</select></td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>  
    </table>
    

     

    And 16:

    http://teamx1.com/lbracket.html

     

    <table align="center" cellpadding="2" cellspacing="0" width="100%">
    	<tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan59">$clan[59]</select></td>
            <td> </td>
        </tr>	  
    	<tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>	  
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan53">$clan[53]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan41">$clan[41]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
    	</tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[21]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan49">$clan[49]</select></td>
            <td style="border-right:2px solid #000000;" align="center">$match[27]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan57">$clan[57]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan33">$clan[33]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td style="border-right:2px solid #000000;" align="center">$match[17]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan42">$clan[42]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan34">$clan[34]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[30]</td>
            <td bgcolor="#efefef" align="center"><select name="lb_winner" onChange="change_clan(this.value, 'clan32')">$clan[lb_winner]</select></td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[25]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan54">$clan[54]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan35">$clan[35]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td style="border-right:2px solid #000000;" align="center">$match[18]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan43">$clan[43]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan36">$clan[36]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center"> $match[22] </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan50">$clan[50]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan44">$clan[44]</select></td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[29] </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan60">$clan[60]</select></td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan45">$clan[45]</select></td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[23]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan51">$clan[51]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan37">$clan[37]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td style="border-right:2px solid #000000;" align="center">$match[19]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan46">$clan[46]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan38">$clan[38]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center">$match[26]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan55">$clan[55]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
    	<tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan39">$clan[39]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td style="border-right:2px solid #000000;" align="center">$match[20]</td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan47">$clan[47]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan40">$clan[40]</select></td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;" align="center"> $match[24] </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan52">$clan[52]</select></td>
            <td style="border-right:2px solid #000000;" align="center">$match[28]</td>
            <td style="border-right:2px solid #000000;" bgcolor="#efefef" align="center"><select name="clan58">$clan[58]</select></td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan48">$clan[48]</select></td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td style="border-right:2px solid #000000;"> </td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
            <td bgcolor="#efefef" style="border-right:2px solid #000000;" align="center"><select name="clan56">$clan[56]</select></td>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>		  
    </table>
    

     

    Possible to be done?

  10. Hi all,

     

    I am trying to construct a HTML table for the loser bracket for a tournament-tree, the upper-bracket

    table structure is more straight forward but I am having difficulty in constructing the lower/loser bracket.

     

     

    This is what I have so far:-

     

    upper_and_lower.png

     

    This is what I am looking for with the lower bracket, this is the structure I need:-

     

    lower.png

     

    Anyone can help me on this please?

    The code for the lowerbracket section is under

    //////////////////////////////// LOWER BRACKET ////////////////////////////////

     

    This is the full code:-

     

    <?php
    
    if(isset($_GET['action'])) $action = $_GET['action'];
    else $action='';
    
    $tourney[id] = 11;
    $tinfo=safe_query("SELECT * FROM tourneys WHERE tid='$tourney[id]'");
    $tinfo=mysql_fetch_array($tinfo);
    
    switch($action){
        case "brackets":
        tourney_brackets();
        break;
    }
    
    function tourney_brackets(){
        global $tinfo, $url, $out, $plyr, $site, $uinfo, $misc, $file;
        $brackets=safe_query("SELECT bid,pid,name FROM brackets2 WHERE tid='$tinfo[tid]' ORDER BY bid");
        while(list($bid,$pid,$name)=mysql_fetch_row($brackets)){
            if($pid){
                $bracket[$bid]="<font type='arial' size='2'><a href='$url[base]/$file[teams]?teamid=$pid'>$name</a></font>";
            }else{
    
                $bracket[$bid]="$name";
            }
    
            $pid="";
        }
    
    $tinfo[size] = 16;
    
        $brackets="$tinfo[size]";
        $spots=($brackets * 2 - 1);
        $temp_rows="$brackets";
        while($temp_rows > 1){
            $rowcount++;
            if($rowcount > 1){
                $temp_rows=($temp_rows / 2);
            }
    
            $listrows.="-> $temp_rows";
            $rows="$rowcount";
        }
    
        $rowwidths=round(100 / $rows - 0.5);
        $actualrows=($rows * 2);
        //////////////////////////////// UPPER BRACKET ////////////////////////////////
        $out[body]=$out[body]."
        <center>
        $bannerhead
        $out[banner]
        $bannerfoot  <br>
        $tablehead    <strong>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr class ='altcolor'>
        <td width='100%' valign='top' align='center'>
        <b>$tinfo[name] Brackets</b><br>
        </td></tr></table>
        <br><br>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr>
        ";
        $counter="$brackets";
    
        while($counter > 1){
    
            if($round){
                $counter=($counter / 2);
            }
    
            $lastcb="$countbrackets";
            $countbrackets="";
            $game="";
            $round++;
            $finals=($rows - 1);
            $winner=($rows);
            $roundgamesay="Round $round Games";
            if($round=="$winner"){
                $roundgamesay="Winner!";
            }
    
            if($round=="$finals"){
                $roundgamesay="Finals";
            }
    
            $out[body]=$out[body]."
            <td align='center' valign='center' width='$rowwidths%' colspan='1' style='border-collapse:collapse; padding: 0px;'><b>$roundgamesay2</b><br>
            <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border' style='border-collapse:collapse; padding: 0px;'>
            ";
            $spacesetcount="";
    
            while($countbrackets < $counter){
                $countbrackets++;
                $spot++;
                $spacesetcount++;
                if($spacesetcount=="4"){
                    $spacesetcount="";
                }
    
                $bracketid="$round"."_"."$countbrackets";
                $out[body]=$out[body]."
                <tr>
                <td align='left' valign='center' width='100%' bgcolor='#e4f3ff'>$bracket[$bracketid] $spot</td>
                <td align='left' ".($round!=$winner ? "style='border-right:2px solid #333333;'" : "")." bgcolor='#D9D9D9' valign='center' width='100%'> </td>
                </tr>
                ";
                if($countbrackets < $counter){
                    $spacecounter++;
                    $spacecounter=($spacecounter + 1);
                    if($spacecounter==2){
                        $roundx2p1=($lastroundx2p1 * 2 + 1);
                        if($round==1){
                            $roundx2p1="1";
                        }
    
                        while($countspaces < $roundx2p1){
                            $countspaces++;      
                            $spacecentercount++;
                            $spacecenterword="";
                            $alignspacer1="left";
                            $spacecentercountcheck=($lastroundx2p1 + 1);
                            if($spacecentercount=="$spacecentercountcheck"){
                                $spacecenterwordcount++;
                                if(($spacecenterwordcount==1)||($spacecenterwordcount==3)){
                                    $actualgamecount++;							
    							$detail = $spot / 2 + 0.5;							
                                    $spacecenterword="<b>Game $actualgamecount2 $detail</b>";
                                    $alignspacer1="center";
    
                                    if($spacecenterwordcount==3){
                                        $spacecenterwordcount="";
                                        $spacecenterwordcount++;
                                    }
                                }
                            }
    
                            $out[body]=$out[body]."
                            <tr>
                            <td align='$alignspacer1' valign='center'>  $spacecenterword</td>
                            <td align='left' valign='center' ".(is_odd($spot) ? "style='border-right:2px solid #333333;'" : "")."> </td>
                            </tr>
                            ";
                        }
    
                        $spacecounter="";
                        $countspaces="";
                        $spacecentercount="";
                    }
    
                }
    
            }
    
            $spacecenterwordcount="";
            $actualgamecount="";
            $lastroundx2p1="$roundx2p1";
            $out[body]=$out[body]."
            </table>
            </td>
            ";
        }
    
    /////////////
    
    unset($spot);
    unset($round);
    
    $spot = $tinfo[size] * 2 + 1;
    $brackets = $tinfo[size] / 2;
    
        //////////////////////////////// LOWER BRACKET ////////////////////////////////
        $out[body]=$out[body]."
        <center>
        $bannerhead
        $out[banner]
        $bannerfoot  <br>
        $tablehead    <strong>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr class ='altcolor'>
        <td width='100%' valign='top' align='center'>
        <b>$tinfo[name] Brackets</b><br>
        </td></tr></table>
        <br><br>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr>
        ";
        $counter="$brackets";
    
        while($counter > 1){
    
        
    
            if($round){
                $counter=($counter / 2);
            }
    
    	$realround = $round + 1;
    
    
    
            $lastcb="$countbrackets";
            $countbrackets="";
            $game="";
            $round++;
            $finals=($rows - 1);
            $winner=($rows);
            $roundgamesay="Round $round Games";
            if($round=="$winner"){
                $roundgamesay="Winner!";
            }
    
            if($round=="$finals"){
                $roundgamesay="Finals";
            }
    
            $out[body]=$out[body]."
            <td align='center' valign='center' width='$rowwidths%' colspan='1' style='border-collapse:collapse; padding: 0px;'><b>$roundgamesay</b><br>
            <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border' style='border-collapse:collapse; padding: 0px;'>
            ";
            $spacesetcount="";
    
            while($countbrackets < $counter){
                $countbrackets++;
                $spot++;
                $spacesetcount++;
                if($spacesetcount=="4"){
                    $spacesetcount="";
                }
    
    
    
                $bracketid="$round"."_"."$countbrackets";
                $out[body]=$out[body]."
                <tr>
                <td align='left' valign='center' width='100%' bgcolor='#e4f3ff'>$bracket[$bracketid] $spot </td>
                <td align='left' ".($round!=$winner ? "style='border-right:2px solid #333333;'" : "")." bgcolor='#D9D9D9' valign='center' width='100%'> </td>
                </tr>
                ";
                if($countbrackets < $counter){
                    $spacecounter++;
                    $spacecounter=($spacecounter + 1);
                    if($spacecounter==2){
                        $roundx2p1=($lastroundx2p1 * 2 + 1);
                        if($round==1){
                            $roundx2p1="1";
                        }
    
                        while($countspaces < $roundx2p1){
                            $countspaces++;      
                            $spacecentercount++;
                            $spacecenterword="";
                            $alignspacer1="left";
                            $spacecentercountcheck=($lastroundx2p1 + 1);
                            if($spacecentercount=="$spacecentercountcheck" || $round==1){
                                $spacecenterwordcount++;
                                if(($spacecenterwordcount==1)||($spacecenterwordcount==3)){
                                    $actualgamecount++;
    							$detail = $spot / 2;
                                    $spacecenterword="<b>Game $actualgamecount2 $detail</b>";
                                    $alignspacer1="center";
    
                                    if($spacecenterwordcount==3){
                                        $spacecenterwordcount="";
                                        $spacecenterwordcount++;
                                    }
                                }
                            }
    
                            $out[body]=$out[body]."
                            <tr>
                            <td align='$alignspacer1' valign='center'>  $spacecenterword</td>
                            <td align='left' valign='center' ".(!is_odd($spot) ? "style='border-right:2px solid #333333;'" : "")."> </td>
                            </tr>
                            ";
                        }
    
                        $spacecounter="";
                        $countspaces="";
                        $spacecentercount="";
                    }
    
                }
    
            }
    
            $spacecenterwordcount="";
            $actualgamecount="";
            $lastroundx2p1="$roundx2p1";
            $out[body]=$out[body]."
            </table>
            </td>
            ";
        }
    
    //////////////////
    
        $out[body]=$out[body]."
        </tr>
        </table><br><br>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr class ='altcolor'>
        <td width='100%' valign='top' align='center'>
        <br>
        </td></tr></table>
        <br>
        $tablefoot";
    
    echo $out[body];
    
    }
    ?>
    

     

    Thanks to all

  11. Hi all,

     

    I am having trouble setting the style border for the right columns, if you are take a look here:-

    http://teamx1.com/popup.php?site=test&action=brackets you can see what I mean.

     

    First and second from last column looks okay but the other columns the border line are all over the place, they should

    only be in between and next to the blue boxes only where it says "Game .." exactly how the first column and "Finals" columns are.

     

    I have defined it in $borderline variable.

     

    Full code:

    <?php
    
    if(isset($_GET['action'])) $action = $_GET['action'];
    else $action='';
    
    $tourney[id] = 11;
    $tinfo=safe_query("SELECT * FROM tourneys WHERE tid='$tourney[id]'");
    $tinfo=mysql_fetch_array($tinfo);
    
    switch($action){
        case "brackets":
        tourney_brackets();
        break;
    }
    
    function table_head($type,$width,$height,$align){
    global $url;
    
    if($type=="show"){
    
    $tablehead="
    <table width='$width' height='$height' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
    <tr>
    <td width='10' height='10' valign='top' align='left'>
    <img src='$url[curtheme]/images/mid_menu_ltcorner.gif'></td>
    <td width='100%' height='10' valign='top' align='left' background='$url[curtheme]/images/mid_menu_tbg.gif'></td>
    <td width='10' height='10' valign='top' align='right'>
    <img src='$url[curtheme]/images/mid_menu_rtcorner.gif'></td>
    </tr>
    <tr>
    <td width='10' height='100%' valign='top' align='left' background='$url[curtheme]/images/mid_menu_lbg.gif'></td>
    <td width='100%' height='100%' valign='top' align='$align'>";
    
    }
    return($tablehead);
    }
    
    function table_foot($type){
    global $url;
    
    if($type=="show"){
    
    $tablefoot="
    </td>
    <td width='10' height='100%' valign='top' align='right' background='$url[curtheme]/images/mid_menu_rbg.gif'></td>
    </tr>
    <tr>
    <td width='10' height='10' valign='top' align='left'>
    <img src='$url[curtheme]/images/mid_menu_lbcorner.gif'></td>
    <td width='100%' height='10' valign='top' align='left' background='$url[curtheme]/images/mid_menu_bbg.gif'></td>
    <td width='10' height='10' valign='top' align='right'>
    <img src='$url[curtheme]/images/mid_menu_rbcorner.gif'></td>
    </tr>
    </table>";
    
    }
    return($tablefoot);
    }
    
    
    function tourney_brackets(){
        global $tinfo, $url, $out, $plyr, $site, $uinfo, $misc, $file;
        $brackets=safe_query("SELECT bid,pid,name FROM brackets2 WHERE tid='$tinfo[tid]' ORDER BY bid");
        while(list($bid,$pid,$name)=mysql_fetch_row($brackets)){
            if($pid){
                $bracket[$bid]="<font type='arial' size='2'><a href='$url[base]/$file[teams]?teamid=$pid'>$name</a></font>";
            }else{
    
                $bracket[$bid]="$name";
            }
    
            $pid="";
        }
    
        $brackets="$tinfo[size]";
        $spots=($brackets * 2 - 1);
        $temp_rows="$brackets";
        while($temp_rows > 1){
            $rowcount++;
            if($rowcount > 1){
                $temp_rows=($temp_rows / 2);
            }
    
            $listrows.="-> $temp_rows";
            $rows="$rowcount";
        }
    
        $rowwidths=round(100 / $rows - 0.5);
        $actualrows=($rows * 2);
        ////////////////////////////////
        $tablehead=table_head("show","100%","","left");
        $tablefoot=table_foot("show");
        $bannerhead=table_head("show","488","80","center");
        $bannerfoot=table_foot("show");
        $out[body]=$out[body]."
        <center>
        $bannerhead
        $out[banner]
        $bannerfoot  <br>
        $tablehead    <strong>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr class ='altcolor'>
        <td width='100%' valign='top' align='center'>
        <b>$tinfo[name] Brackets</b><br>
        </td></tr></table>
        <br><br>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr>
        ";
        $counter="$brackets";
    
        while($counter > 1){
    
            if($round){
                $counter=($counter / 2);
            }
    
            $lastcb="$countbrackets";
            $countbrackets="";
            $game="";
            $round++;
            $finals=($rows - 1);
            $winner=($rows);
            $roundgamesay="Round $round Games";
            if($round=="$winner"){
                $roundgamesay="Winner!";
            }
    
            if($round=="$finals"){
                $roundgamesay="Finals";
            }
    
            $out[body]=$out[body]."
            <td align='center' valign='center' width='$rowwidths%' colspan='2'><b>$roundgamesay</b><br>
            <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
            ";
            $spacesetcount="";
    
            while($countbrackets < $counter){
                $countbrackets++;
                $spot++;
                $spacesetcount++;
                if($spacesetcount=="4"){
                    $spacesetcount="";
                }
    
                $bracketid="$round"."_"."$countbrackets";
                $out[body]=$out[body]."
                <tr>
                <td align='left' valign='center' width='100%' bgcolor='#e4f3ff'>$bracket[$bracketid]</td>
                <td align='left' style='border-right:2px solid #333333;' bgcolor='#D9D9D9' valign='center' width='100%'> </td>
                </tr>
                ";
                if($countbrackets < $counter){
                    $spacecounter++;
                    $spacecounter=($spacecounter + 1);
                    if($spacecounter==2){
                        $roundx2p1=($lastroundx2p1 * 2 + 1);
                        if($round==1){
                            $roundx2p1="1";
                        }
    
                        while($countspaces < $roundx2p1){
                            $countspaces++;      
                            $spacecentercount++;
                            $spacecenterword="";
                            $alignspacer1="left";
                            $spacecentercountcheck=($lastroundx2p1 + 1);
                            if($spacecentercount=="$spacecentercountcheck"){
                                $spacecenterwordcount++;
                                if(($spacecenterwordcount==1)||($spacecenterwordcount==3)){
                                    $actualgamecount++;
                                    $spacecenterword="<b>Game $actualgamecount</b>";
                                    $alignspacer1="center";
    
    							if(!empty($spacecenterword))								
    							$borderline = "style='border-right:2px solid #333333;'";
    
                                    if($spacecenterwordcount==3){
                                        $spacecenterwordcount="";
                                        $spacecenterwordcount++;
                                    }
    
                                }
    						else
    							$borderline = "";
    
                            }
    
                            $out[body]=$out[body]."
                            <tr>
                            <td align='$alignspacer1' valign='center'>  $spacecenterword</td>
                            <td align='left' valign='center' ".$borderline."> </td>
                            </tr>
                            ";
                        }
    
                        $spacecounter="";
                        $countspaces="";
                        $spacecentercount="";
                    }
    
                }
    
            }
    
            $spacecenterwordcount="";
            $actualgamecount="";
            $lastroundx2p1="$roundx2p1";
            $out[body]=$out[body]."
            </table>
            </td>
            ";
        }
    
        $out[body]=$out[body]."
        </tr>
        </table><br><br>
        <table width='100%' cellspacing='$cellspacing' cellpadding='$cellpadding' bgcolor='$border'>
        <tr class ='altcolor'>
        <td width='100%' valign='top' align='center'>
        <br>
        </td></tr></table>
        <br>
        $tablefoot";
    
    echo $out[body];
    
    }
    ?>
    

     

    Any help on this would be great, thanks to anyone.  :)

  12. Hi,

     

    Can anyone understand what I'm trying to do in code?

    I have difficulty explaining, trying to set variable for numbers starting with 0,1 in the sequence in for loop:-

     

    Every number after the next you will see the pattern:

     

    8

    4

    7

    3

    6

    2

    5

     

            for($i = 1; $i <= 8; $i++){
    
        $val = "LIMIT 0,1
                LIMIT 8,1
                LIMIT 4,1
                LIMIT 7,1
                LIMIT 3,1
                LIMIT 6,1
                LIMIT 2,1
                LIMIT 5,1";
    
        $clan_val = "LIMIT ".$val.",1";
    
        $query = "SELECT clan1 FROM ".PREFIX."cup_matches WHERE type='gs' AND $type_opp='0' AND matchno='{$ID}' ORDER BY clan1 ASC ".{$clan_val};
                safe_query($query);
            }
    

     

    Hope you understand  8)

  13. I'm no wizz at logics and mathematics but you are making it seem more complicated than it seems, the query fetches ALL combinations, there is two unions in the query now and if max is reached it will always have 28 matches per group.

     

    if 4 matches in each group (which will be for 8 players) 4 times 7 = 28

     

    Where in this pic do you see a missed combination? Each player has 7 matches each.

    http://s13.postimage.org/i2apegtz9/solved.png

     

    solved.png

     

    The complicated theory now is assigning weeks..

     

     

  14. How are you expecting to update seven different records with the same WHERE clause? Do you see why that doesn't make any sense, and will never work?

     

    I do understand what you are saying but you still unsure what I am trying to do?

    I am able to fetch 7 rows and simply want to update each row to set value 1,2,3,4,5,6 and 7.

  15. This is what I get and I want it like this:-

     

    UPDATE ws_bi2_cup_matches SET wk='1' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    UPDATE ws_bi2_cup_matches SET wk='2' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    UPDATE ws_bi2_cup_matches SET wk='3' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    UPDATE ws_bi2_cup_matches SET wk='4' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    UPDATE ws_bi2_cup_matches SET wk='5' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    UPDATE ws_bi2_cup_matches SET wk='6' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    UPDATE ws_bi2_cup_matches SET wk='7' WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'
    

     

    But when I select:

     

    SELECT *

    FROM  `ws_bi2_cup_matches`

    WHERE  WHERE type='gs' && ladID='0' && matchno='6' && clan1='1'

     

    Each 7 rows has a set value of "7" ?

    Pic: http://s16.postimage.org/i3zumstv7/prob6.png

     

    1st row should have 1..

    2nd row 2..

    3rd row 3.. so forth.

  16. I am trying to update 7 rows by setting the "wk" column in the sequence 1-7,

    so each row will have "wk" set to 1-7, right now the query is updating all rows and setting wk column to 7 and not 1-7?

     

    for($i = 1; $i <= 7; $i++) {
            safe_query("UPDATE ".PREFIX."cup_matches SET wk='$i' WHERE type='gs' && $type_opp='0' && matchno='$ID' && clan1='".$sPT['clan1']."'");	    
           }
    

     

    Any help on this please?

     

  17. Algorithm for assigning week is something you have to implement outside mysql.

     

    And it depends on how many players are there in each group (MIN and MAX possible values) and number of players in each group are always equal or not ?

     

    A player plays only one match in a week is strictly true or it changes based on number of matches.

     

    you haven't provide any of these details .....and still expect understand or assume everything correctly.

     

     

     

    Finally the query is ok now :)

    The second part of it is to split in weekly divisions..

     

    Ok,

     

    -> each group will have even amount of teams

    -> 7 matches per team is for 7 weeks, each match per week

    -> league is not limited to max signups

     

    if league is for 16 teams there will only be 2 groups, a and b:

     

    min: 4 per group

    max: 8 per group

     

    -> group a which holds up to 8 teams

    -> group b which holds up to 8 teams

    -> all vs. all therefore is 16/2 * 7 weeks = 56 max matches (28 matches for group a and 28 for group b)

     

    if league is for 32 teams there will only be 4 groups, a, b, c and d:

     

    min: 4 per group

    max: 8 per group

     

    -> each group holds up to 8 teams each

    -> all vs. all therefore is 32/2 * 7 weeks = 112 matches (112 / 4 groups  = 28 matches in each group)

     

    if league is for 64 teams there will be 8 groups (a-h):

     

    min: 4 per group

    max: 8 per group

     

    -> each group holds up to 8 teams each

    -> all vs. all therefore is 64/2 * 7 =  224 matches (224 / 8 groups = 28 matches in each group)

     

    if league is for 128 teams there will be 8 groups (a-h);

     

    min: 8 per group

    max: 16 per group

     

    -> each group holds up to 16 teams each

    -> all vs. all therefore is 128/2 * 7 = 448 matches (448 / 8 groups = 56 matches in each group)

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