[php] array sortering op meerdere array's

Pagina: 1
Acties:
  • 100 views sinds 30-01-2008
  • Reageer

Onderwerpen


Acties:
  • 0 Henk 'm!

  • VIsje
  • Registratie: Oktober 2000
  • Laatst online: 20-09 22:24

VIsje

keeper s.v. de Glind 2

Topicstarter
Ik ben bezig met een webapplicatie die de competitie stand bijhoud.
Daarvoor heb ik twee tabellen aangemaakt.
De eerste tabel is met alle teamnamen erin.
De tweede tabel is een tabel met alle gegevens:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CREATE TABLE `svdeglind_stand_gegevens` (
  `ID` int(10) NOT NULL auto_increment,
  `datum` datetime NOT NULL default '0000-00-00 00:00:00',
  `thuis_team` int(4) NOT NULL default '0',
  `uit_team` int(4) NOT NULL default '0',
  `thuis_doelpunt` int(4) NOT NULL default '0',
  `uit_doelpunt` int(4) NOT NULL default '0',
  `thuis_punt` int(4) NOT NULL default '0',
  `uit_punt` int(4) NOT NULL default '0',
  `team` varchar(40) NOT NULL default '',
  `seizoen` varchar(40) NOT NULL default '',
  `mindering` int(4) NOT NULL default '0',
  `periode` int(4) NOT NULL default '0',
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;


Hierin staan dus alle gegevens.
Nu heb ik het volgende php script gemaakt met behulp van een ander php script:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
    //Teams binnen halen
        $get_teams = mysql_query("
        SELECT 
        ID, naam
        FROM svdeglind_stand_teams
        WHERE 
        seizoen = '$seizoen' AND
        team = '$team' 
        ")
        or die(mysql_error());
    
        while($data = mysql_fetch_array($get_teams))
        {
            $teamid[$i] = $data['ID'];
            $team_naam = $data['naam'];
            
        
    //thuis punten
    $query = mysql_query("
                SELECT
                SUM(thuis_punt) AS thuis_punten
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                thuis_team = '$teamid[$i]'
                ") 
                or die(mysql_error());

                $mdata = mysql_fetch_array($query);
                $thuis_punten[$i] = $mdata['thuis_punten'];

                mysql_free_result($query);
    
    //uit punten
    $query = mysql_query("
                SELECT
                SUM(uit_punt) AS uit_punten
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                uit_team = '$teamid[$i]'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $uit_punten[$i] = $mdata['uit_punten'];
    
                mysql_free_result($query);

    //doelpunten
    $query = mysql_query("
                SELECT
                SUM(uit_doelpunt) AS uit_doelpunt_voor,
                SUM(thuis_doelpunt) AS thuis_doelpunt_tegen
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                uit_team = '$teamid[$i]'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $uit_doelpunt_voor[$i] = $mdata['uit_doelpunt_voor'];
                $thuis_doelpunt_tegen[$i] = $mdata['thuis_doelpunt_tegen'];
    
                mysql_free_result($query);
    
    $query = mysql_query("
                SELECT
                SUM(thuis_doelpunt) AS thuis_doelpunt_voor,
                SUM(uit_doelpunt) AS uit_doelpunt_tegen
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                thuis_team = '$teamid[$i]'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $thuis_doelpunt_voor[$i] = $mdata['thuis_doelpunt_voor'];
                $uit_doelpunt_tegen[$i] = $mdata['uit_doelpunt_tegen'];
    
                mysql_free_result($query);      
    //gelijkspel
    $query = mysql_query("
                SELECT
                COUNT(thuis_punt) AS thuis_gelijkspel
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                thuis_team = '$teamid[$i]' AND
                thuis_punt = '1'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $thuis_gelijkspel[$i] = $mdata['thuis_gelijkspel'];
    
                mysql_free_result($query);  

    $query = mysql_query("
                SELECT
                COUNT(uit_punt) AS uit_gelijkspel
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                uit_team = '$teamid[$i]' AND
                uit_punt = '1'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $uit_gelijkspel[$i] = $mdata['uit_gelijkspel'];
    
                mysql_free_result($query);  

    //verlies
    $query = mysql_query("
                SELECT
                COUNT(thuis_punt) AS thuis_verlies
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                thuis_team = '$teamid[$i]' AND
                thuis_punt = '0' AND
                mindering = '0'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $thuis_verlies[$i] = $mdata['thuis_verlies'];
    
                mysql_free_result($query);  

    $query = mysql_query("
                SELECT
                COUNT(uit_punt) AS uit_verlies
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                uit_team = '$teamid[$i]' AND
                uit_punt = '0' AND
                mindering = '0'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $uit_verlies[$i] = $mdata['uit_verlies'];
    
                mysql_free_result($query);  

    //winst
    $query = mysql_query("
                SELECT
                COUNT(thuis_punt) AS thuis_winst
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                thuis_team = '$teamid[$i]' AND
                thuis_punt = '3'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $thuis_winst[$i] = $mdata['thuis_winst'];
    
                mysql_free_result($query);  

    $query = mysql_query("
                SELECT
                COUNT(uit_punt) AS uit_winst
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                uit_team = '$teamid[$i]' AND
                uit_punt = '3'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $uit_winst[$i] = $mdata['uit_winst'];
    
                mysql_free_result($query);

    //mindering
    $query = mysql_query("
                SELECT
                SUM(mindering) AS mindering
                FROM
                svdeglind_stand_gegevens
                WHERE
                seizoen = '$seizoen' AND
                team = '$team' AND
                thuis_team = '$teamid[$i]'
                ") 
                or die(mysql_error());
    
                $mdata = mysql_fetch_array($query);
                $mindering[$i] = $mdata['mindering'];
    
                mysql_free_result($query);  

    //berekeningen
    $punten[$i]=($thuis_punten[$i]+$uit_punten[$i]-$mindering[$i]);
    $doelpunten_voor[$i]=($thuis_doelpunt_voor[$i]+$uit_doelpunt_voor[$i]);
    $doelpunten_tegen[$i]=($thuis_doelpunt_tegen[$i]+$uit_doelpunt_tegen[$i]);
    $doelpunten_saldo[$i] = ($doelpunten_voor[$i]-$doelpunten_tegen[$i]);
    $gelijkspel[$i] = ($thuis_gelijkspel[$i]+$uit_gelijkspel[$i]);
    $verlies[$i] = ($thuis_verlies[$i]+$uit_verlies[$i]);
    $winst[$i] = ($thuis_winst[$i]+$uit_winst[$i]);
    $gespeeld[$i] = ($gelijkspel[$i]+$winst[$i]+$verlies[$i]);

    //nu gaan we alles sorteren
    array_multisort($punten, SORT_ASC, SORT_NUMERIC, $doelpunten_saldo, SORT_ASC, SORT_NUMERIC);


Het probleem is alleen dat de sortering niet wil lukken. Ik krijg met geen mogelijkheid de gegevens gesorteerd op totaal punten en daarna op doelsaldo. Terwijl in het andere script op dezelfde manier de sortering is en dit wel goed gaat.

Ik lees de array's zo uit:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    <tr>
        <td width="300">
        <?php 
        $query = mysql_query("SELECT * FROM svdeglind_stand_teams WHERE ID = '$teamid[$i]'") or die (mysql_error());
                    while ($obj = mysql_fetch_object($query)) {
                    $naam = $obj->naam;
                    }
        echo $naam; 
        ?>
        </td>
        <td width="30">
        <center>
        <?php echo $gespeeld[$i]; ?>
        </center>
        </td>       
        <td width="30">
        <center>
        <?php echo $winst[$i]; ?>
        </center>
        </td>
        <td width="30">
        <center>
        <?php echo $gelijkspel[$i]; ?>
        </center>
        </td>
        <td width="30">
        <center>
        <?php echo $verlies[$i]; ?>
        </center>
        </td>
        <td width="30">
        <center>
        <b>
        <?php echo $punten[$i]; ?>
        </b>
        </center>
        </td>
        <td width="30">
        <center>
        <?php echo $doelpunten_voor[$i]; ?>
        </center>
        </td>
        <td width="30">
        <center>
        <?php echo $doelpunten_tegen[$i]; ?>
        </center>
        </td>
        <td width="30">
        <center>
        <?php echo $doelpunten_saldo[$i]; ?>
        </center>
        </td>
        <td width="30">
        <center>
        <?php echo $mindering[$i]; ?>
        </center>
        </td>
    </tr>
<?php
        }
    ?>
</table>


Weet iemand wat ik fout doe? Zit er al twee dagen aan te werken en snap het nu ff niet meer.

I'm proudly present you: www.bertverbeek.nl
Wie dit leest is ......
specs.
En keeper van s.v. de Glind 2


Acties:
  • 0 Henk 'm!

  • DirkT
  • Registratie: Juli 2002
  • Niet online

DirkT

toet

Het eerste wat me opvalt is dat je zoveel kleine queries gebruikt, je kan deze ook versimpelen naar 1 grotere query, ik denk dat voornamelijk je mysql socket daar een stuk sneller van wordt.

Daarnaast bied mysql tijdens selectie ook sortering, misschien moet je daar eens naar kijken

edit:
misschien niet 1 maar wel minder :)

[ Voor 9% gewijzigd door DirkT op 15-07-2006 15:28 ]

iRacing profiel - FanaLEDs voor je racesimulatie displays en meer!


Acties:
  • 0 Henk 'm!

  • Annie
  • Registratie: Juni 1999
  • Laatst online: 25-11-2021

Annie

amateur megalomaan

Je kan met 2 queries alle gegevens ophalen die je wil (eentje voor de thuisspelende ploegen en eentje voor de uitspelende ploegen). Als je daarna de uitkomsten van beide queries optelt heb je voor elk team alle gegevens. Dat is al een stuk korter dan de code die je hierboven hebt.

Mijn queries voor een voetbalpool zagen er zo uit:
SQL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
select
  teamHomeId, 
  count(*) as games,
  sum(matchHomeScore) as goals_pro,
  sum(matchAwayScore) as goals_con,
  count(if(matchHomeScore>matchAwayScore,1,null)) as wins,
  count(if(matchHomeScore=matchAwayScore,1,null)) as draws,
  count(if(matchHomeScore<matchAwayScore,1,null)) as losses
from worldcup_matches
group by teamHomeId

select
  teamAwayId, 
  count(*) as games,
  sum(matchAwayScore) as goals_pro,
  sum(matchHomeScore) as goals_con,
  count(if(matchHomeScore<matchAwayScore,1,null)) as wins,
  count(if(matchHomeScore=matchAwayScore,1,null)) as draws,
  count(if(matchHomeScore>matchAwayScore,1,null)) as losses
from worldcup_matches
group by teamAwayId

Het idee lijkt me duidelijk. Dus dat moet je wel makkelijk om kunnen schrijven naar jouw model.

Blijft vervolgens natuurlijk het probleem hoe je dat krijgt gesorteerd. Ik heb dat zelf bij de voetbalpool gedaan met uasort (omdat ik wat ingewikkeldere sorteerregels had; o.a. onderling resultaat).

Maar als je alle gegevens uit bovenstaande queries plaatst in 1 multi-dimensionele array (een array met arrays voor elk team), dan kan je met array_multisort sorteren op meerdere indices.

[ Voor 23% gewijzigd door Annie op 15-07-2006 18:16 ]

Today's subliminal thought is:


Acties:
  • 0 Henk 'm!

  • VIsje
  • Registratie: Oktober 2000
  • Laatst online: 20-09 22:24

VIsje

keeper s.v. de Glind 2

Topicstarter
Ok heb de code aangepast en idd naar 3 query's gedaan.
Alleen krijg de array sortering weer niet voor elkaar :?

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
                //Teams binnen halen
            $get_teams = mysql_query("
            SELECT 
            ID, naam
            FROM svdeglind_stand_teams
            WHERE 
            seizoen = '$seizoen' AND
            team = '$team' 
            ")
            or die(mysql_error());
        
            while($data = mysql_fetch_array($get_teams))
            {
            $teamid[$i] = $data['ID'];
            $team_naam = $data['naam'];
            
            //query voor het thuis team
            $query_thuis = mysql_query("
            select 
              thuis_team,  
              count(*) as thuis_wedstrijden, 
              sum(thuis_doelpunt) as thuis_doelpunten_voor,
              sum(uit_doelpunt) as thuis_doelpunten_tegen,  
              count(if(thuis_doelpunt>uit_doelpunt,1,null)) as thuis_winst, 
              count(if(thuis_doelpunt=uit_doelpunt,1,null)) as thuis_gelijkspel, 
              count(if(thuis_doelpunt<uit_doelpunt,1,null)) as thuis_verlies 
            from svdeglind_stand_gegevens
            WHERE thuis_team = $teamid[$i]
            group by thuis_team
            ") or die (mysql_error());
            
            //query voor het uit team
            $query_uit = mysql_query("
            select 
              uit_team,  
              count(*) as uit_wedstrijden, 
              sum(uit_doelpunt) as uit_doelpunten_voor, 
              sum(thuis_doelpunt) as uit_doelpunten_tegen, 
              count(if(thuis_doelpunt<uit_doelpunt,1,null)) as uit_winst, 
              count(if(thuis_doelpunt=uit_doelpunt,1,null)) as uit_gelijkspel, 
              count(if(thuis_doelpunt>uit_doelpunt,1,null)) as uit_verlies 
            from svdeglind_stand_gegevens
            WHERE uit_team = $teamid[$i]
            group by uit_team
            ") or die (mysql_error());

            //query voor de vermindering van punten
            $query_mindering = mysql_query("
            select 
              punten
            from svdeglind_stand_mindering
            WHERE team_id = $teamid[$i]
            group by team_id
            ") or die (mysql_error());

            
            $thuis_data = mysql_fetch_array($query_thuis);
            $uit_data = mysql_fetch_array($query_uit);
            $mindering_data = mysql_fetch_array($query_mindering);

            $stand[$data['ID']]['naam'] = $team_naam;
            $stand[$data['ID']]['gespeeld'] = ($uit_data['uit_wedstrijden']+$thuis_data['thuis_wedstrijden']);
            $stand[$data['ID']]['winst'] = ($uit_data['uit_winst']+$thuis_data['thuis_winst']);
            $stand[$data['ID']]['verlies'] = ($uit_data['uit_verlies']+$thuis_data['thuis_verlies']);
            $stand[$data['ID']]['gelijkspel'] = ($uit_data['uit_gelijkspel']+$thuis_data['thuis_gelijkspel']);
            $stand[$data['ID']]['punten'] = (($stand[$data['ID']]['winst']*3) + ($stand[$data['ID']]['gelijkspel']*1) - $mindering_data['punten']);
            $stand[$data['ID']]['doelpunten_voor'] = ($thuis_data['thuis_doelpunten_voor'] + $uit_data['uit_doelpunten_voor']);
            $stand[$data['ID']]['doelpunten_tegen'] = ($thuis_data['thuis_doelpunten_tegen'] + $uit_data['uit_doelpunten_tegen']);
            $stand[$data['ID']]['doelpunten_saldo'] = ($stand[$data['ID']]['doelpunten_voor'] - $stand[$data['ID']]['doelpunten_tegen']);
            $stand[$data['ID']]['mindering'] = $mindering_data['punten'];

        
    //nu gaan we alles sorteren
    array_multisort($stand[$data['ID']]['punten'], SORT_ASC, SORT_NUMERIC, $stand[$data['ID']]['doelpunten_saldo'], SORT_ASC, SORT_NUMERIC);

    //print_r($stand);
            
?>

I'm proudly present you: www.bertverbeek.nl
Wie dit leest is ......
specs.
En keeper van s.v. de Glind 2


Acties:
  • 0 Henk 'm!

  • Annie
  • Registratie: Juni 1999
  • Laatst online: 25-11-2021

Annie

amateur megalomaan

Je hebt 'm nog niet helemaal door volgens mij. Je voert nu voor elk team deze queries uit. Het hele idee achter de group by is juist dat je de geaggregeerde data in één keer krijgt.

Als je vervolgens (met mysql_fetch_assoc?) een array bouwt met de vorm
code:
1
2
3
4
5
array (
  array(wedstrijden => X, punten => Y, enz),
  array(wedstrijden => X, punten => Y, enz),
  enz.
)

Dan kan je met multisort de complete array sorteren op de gewenste waarden. Ik zie op de php site dat je daarvoor de volgende techniek moet gebruiken.

[ Voor 6% gewijzigd door Annie op 15-07-2006 20:49 ]

Today's subliminal thought is:


Acties:
  • 0 Henk 'm!

  • VIsje
  • Registratie: Oktober 2000
  • Laatst online: 20-09 22:24

VIsje

keeper s.v. de Glind 2

Topicstarter
Ok bedankt. Het werkt nu.
Heb het zo opgelost:

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
            $periode = $_GET['periode'];
        
        $query_teams = mysql_query("
            select 
            ID, naam
            from svdeglind_stand_teams
            WHERE team = '$team' AND
            seizoen = '$seizoen' 
            ") or die (mysql_error());
            while ($obj = mysql_fetch_object($query_teams)) {
    
            //query voor het thuis team
            $query_thuis = mysql_query("
            select 
              thuis_team,  
              count(*) as thuis_wedstrijden, 
              sum(thuis_doelpunt) as thuis_doelpunten_voor,
              sum(uit_doelpunt) as thuis_doelpunten_tegen,  
              count(if(thuis_doelpunt>uit_doelpunt,1,null)) as thuis_winst, 
              count(if(thuis_doelpunt=uit_doelpunt,1,null)) as thuis_gelijkspel, 
              count(if(thuis_doelpunt<uit_doelpunt,1,null)) as thuis_verlies 
            from svdeglind_stand_gegevens
            WHERE team = '$team' AND
            seizoen = '$seizoen' AND
            periode = '$periode' AND
            thuis_team = '$obj->ID'
            group by thuis_team
            ") or die (mysql_error());
            
            //query voor het uit team
            $query_uit = mysql_query("
            select 
              uit_team,  
              count(*) as uit_wedstrijden, 
              sum(uit_doelpunt) as uit_doelpunten_voor, 
              sum(thuis_doelpunt) as uit_doelpunten_tegen, 
              count(if(thuis_doelpunt<uit_doelpunt,1,null)) as uit_winst, 
              count(if(thuis_doelpunt=uit_doelpunt,1,null)) as uit_gelijkspel, 
              count(if(thuis_doelpunt>uit_doelpunt,1,null)) as uit_verlies 
            from svdeglind_stand_gegevens
            WHERE team = '$team' AND
            seizoen = '$seizoen' AND
            periode = '$periode' AND
            uit_team = '$obj->ID'
            group by uit_team
            ") or die (mysql_error());

            //query voor de vermindering van punten
            
            
            
            
            $query_mindering = mysql_query("
            select 
            sum(punten) AS mindering 
            from svdeglind_stand_mindering
            WHERE team = '$team' AND
            seizoen = '$seizoen' AND
            periode = '$periode' AND
            team_id = '$obj->ID'
            ") or die (mysql_error());

            $thuis_data = mysql_fetch_assoc($query_thuis);
            $uit_data = mysql_fetch_assoc($query_uit);
            $mindering_data = mysql_fetch_assoc($query_mindering);
            
            $mindering = $mindering_data['mindering'];
            IF ($mindering == NULL){
            $mindering_null = 0;
            } else {
            $mindering_null = $mindering_data['mindering'];
            }
            
            $stand[] = array(
            'naam' => ($obj->ID),
            'gespeeld' => ($uit_data['uit_wedstrijden']+$thuis_data['thuis_wedstrijden']), 
            'winst' => ($uit_data['uit_winst']+$thuis_data['thuis_winst']),
            'gelijkspel' => ($uit_data['uit_gelijkspel']+$thuis_data['thuis_gelijkspel']),
            'verlies' => ($uit_data['uit_verlies']+$thuis_data['thuis_verlies']),
            'punten' => ((($uit_data['uit_winst']+$thuis_data['thuis_winst'])*3) + ($uit_data['uit_gelijkspel']+$thuis_data['thuis_gelijkspel']) - ($mindering_data['mindering'])),
            'doelpunten_voor' => ($thuis_data['thuis_doelpunten_voor'] + $uit_data['uit_doelpunten_voor']),
            'doelpunten_tegen' => ($thuis_data['thuis_doelpunten_tegen'] + $uit_data['uit_doelpunten_tegen']),
            'doelpunten_saldo' => ($thuis_data['thuis_doelpunten_voor'] + $uit_data['uit_doelpunten_voor']) - ($thuis_data['thuis_doelpunten_tegen'] + $uit_data['uit_doelpunten_tegen']),
            'mindering' => $mindering_null
            );
            }

            foreach ($stand as $key => $row) {
            $punten[$key]  = $row['punten'];
            $doelpunten_saldo[$key] = $row['doelpunten_saldo'];
            $gespeeld[$key] = $row['gespeel'];
            $naam[$key] = $row['naam'];
            $winst[$key] = $row['winst'];
            $gelijkspel[$key] = $row['gelijkspel'];
            $verlies[$key] = $row['verlies'];
            $doelpunten_voor[$key] = $row['doelpunten_voor'];
            $doelpunten_tegen[$key] = $row['doelpunten_tegen'];
            $mindering[$key] = $row['mindernig'];
            }

    //nu gaan we alles sorteren
    array_multisort($punten, SORT_DESC, $doelpunten_saldo, SORT_DESC, $gespeeld, SORT_DESC, $naam, $winst, $gelijkspel, $verlies, $doelpunten_voor, $doelpunten_tegen, $mindering, $stand);
    
    $positie = 0;
    foreach ($stand as $kolom) {
    $positie++;

?>
    
    <tr>
        <td width="30">
        <b><?php 
        IF ($positie == 1) {
        echo $positie; 
        echo "<hr size=1 color=#FF6600>";
    } else {
        echo $positie; 
    }
        ?>
        </b>
        <td width="300">
        <?php
        
        $team_id = $kolom['naam'];
        $query_teams = mysql_query("
            select 
            ID, naam
            from svdeglind_stand_teams
            WHERE team = '$team' AND
            seizoen = '$seizoen' AND
            ID = '$team_id' 
            ") or die (mysql_error());
            while ($obj = mysql_fetch_object($query_teams)) {
        IF ($positie == 1) {
        echo $obj->naam;
        echo "<hr size=1 color=#FF6600>";
    } else {
        echo $obj->naam; 
    }
        
            }
        ?>
        </td>
        <td width="30">
        <center>        
        <?php 
        IF ($positie == 1) {
        echo $kolom['gespeeld']; 
        echo "<hr size=1 color=#FF6600>";
    } else {
        echo $kolom['gespeeld'];
    }   
        ?>
        </center>
        </td>       

I'm proudly present you: www.bertverbeek.nl
Wie dit leest is ......
specs.
En keeper van s.v. de Glind 2

Pagina: 1