Add a table column
Results 1 to 6 of 6

Thread: Add a table column

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    6

    Add a table column

    I want to add a column named "Position" to the left of the "team" column. In this column I want "1" "2" and "3" under the column. I have tried to put this outside the loop but it hasn't worked. How would I do this ? The code I am using is

    Code:
     <table border ="1">
      
      
    
        <tr>
    
      `<td>Team</td> <td>Goals For</td>  <td>GD</td> <td>Points</td></tr>`
      
      
      
      <?php
       while($column = mysql_fetch_array($league_table))
       {
      
          echo" 
            
    			
                
    			<td> $column[team] </td>
    			<td> $column[goals]</td>
    			<td> $column[difference]</td>
    			<td>$column[points]</tr></td>
                 
                </tr>";
            }
    		?>
            </table>

  2. #2
    Senior Member autocolismo's Avatar
    Join Date
    Sep 2002
    Location
    Portugal
    Posts
    178
    don't know if it's your problem but there's an </tr> that shouldn't be there:
    Code:
    <td>$column[points]</tr></td>
    ..:oOOoo::..

  3. #3
    Senior Member autocolismo's Avatar
    Join Date
    Sep 2002
    Location
    Portugal
    Posts
    178
    PHP Code:
      <?php
       
    while($column mysql_fetch_array($league_table))
       {
      
          echo

            
                
                <tr>
                <td> 
    $column[team] </td>
                <td> 
    $column[goals]</td>
                <td> 
    $column[difference]</td>
                <td>
    $column[points]</td>
                 
                </tr>"
    ;
            }
            
    ?>
    ..:oOOoo::..

  4. #4
    newbie php developer Damian_'s Avatar
    Join Date
    Jun 2011
    Location
    london
    Posts
    93
    Oh i think i know what you mean

    PHP Code:

      <?php
    $i 
    1;
       while(
    $column mysql_fetch_array($league_table))
       {
      
          echo

            
                
                <tr>
                <td> 
    $i </td>
                <td> 
    $column[team] </td>
                <td> 
    $column[goals]</td>
                <td> 
    $column[difference]</td>
                <td>
    $column[points]</td>
                 
                </tr>"
    ;
    $i++;
            }
            
    ?>
    try that?

  5. #5
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Quote Originally Posted by Damian_ View Post
    Oh i think i know what you mean

    PHP Code:

      <?php
    $i 
    1;
       while(
    $column mysql_fetch_array($league_table))
       {
      
          echo

            
                
                <tr>
                <td> 
    $i </td>
                <td> 
    $column[team] </td>
                <td> 
    $column[goals]</td>
                <td> 
    $column[difference]</td>
                <td>
    $column[points]</td>
                 
                </tr>"
    ;
    $i++;
            }
            
    ?>
    try that?
    That works exactly how I wanted it to . Thanks very much

  6. #6
    Junior Member
    Join Date
    Feb 2013
    Posts
    6
    Don't know if you would be able to help me anymore possibly? I'm now trying to work the amount of wins, draws and losses each team has and place this on the league table, also the goals conceded as for some reason only the goals for calculated. Below is the code that I have used to calculate the points, goals for and goal difference headings:

    Code:
        $league_table = mysql_query("SELECT team,sum(goals) as goals,sum(points) as points, (difference) as difference FROM(
     SELECT fixtures.hometeam as team, sum(results.homegoals) as goals,sum(results.homepoints) as points,(results.homegoals - results.awaygoals) as difference
      FROM fixtures inner join results on results.fixtureteams = fixtures.fixtureid
      where fixtures.leaguename='$leaguename' 
      group by fixtures.hometeam
      union
      
      SELECT fixtures.awayteam as team, sum(results.awaygoals) as goals,sum(results.awaypoints) as points, (results.awaygoals-results.homegoals) as difference
      from fixtures inner join results on results.fixtureteams = fixtures.fixtureid
      where fixtures.leaguename= '$leaguename'   
      group by fixtures.awayteam
      ) as league group by team order by points desc, difference desc");
    
    
      ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •