bonjour tout le monde,
J'ai un petit soucis avec un script en php.
Pour résumer, j'ai 2 joueurs et je voudrais calculer une performance.
j'ai donc 2 tables:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 CREATE TABLE IF NOT EXISTS `joueur_1` ( `id` int(10) NOT NULL AUTO_INCREMENT, `ronde` int(10) DEFAULT NULL, `joueur_id` varchar(50) DEFAULT NULL, `couleur` varchar(10) DEFAULT NULL, `point` varchar(10) DEFAULT NULL, `tournois_id` int(10) DEFAULT NULL, `appariement` int(10) DEFAULT NULL, `table` int(11) DEFAULT NULL, `Performance` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Contenu de la table `joueur_1` -- INSERT INTO `joueur_1` (`id`, `ronde`, `joueur_id`, `couleur`, `point`, `tournois_id`, `appariement`, `table`, `Performance`) VALUES (1, 1, '1', 'Blanc', '1', 1, 1, 1, NULL), (2, 1, '5', 'Blanc', '0', 1, 2, 2, NULL), (3, 1, '8', 'Blanc', '0.5', 1, 3, 3, NULL), (4, 1, '2', 'Blanc', '0', 1, 4, 4, NULL), (5, 1, '4', 'Blanc', '1', 1, 5, 5, NULL);
Pour calculer le performance du joueur1.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 CREATE TABLE IF NOT EXISTS `joueur_2` ( `id` int(10) NOT NULL AUTO_INCREMENT, `ronde` int(10) DEFAULT NULL, `joueur_id` varchar(50) DEFAULT NULL, `couleur` varchar(10) DEFAULT NULL, `point` varchar(10) DEFAULT NULL, `tournois_id` int(10) DEFAULT NULL, `appariement` int(11) DEFAULT NULL, `table` int(11) DEFAULT NULL, `Performance` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; -- -- Contenu de la table `joueur_2` -- INSERT INTO `joueur_2` (`id`, `ronde`, `joueur_id`, `couleur`, `point`, `tournois_id`, `appariement`, `table`, `Performance`) VALUES (1, 1, '9', 'Noir', '0', 1, 6, 1, NULL), (2, 1, '3', 'Noir', '1', 1, 7, 2, NULL), (3, 1, '7', 'Noir', '0.5', 1, 8, 3, NULL), (4, 1, '10', 'Noir', '1', 1, 9, 4, NULL), (5, 1, '6', 'Noir', '0', 1, 10, 5, NULL);
Je dois prendre le classement du joueur adverse.
Ensuite regarde si le joueur1 a gagné
-si c'est le cas je prend le classement du joueur adverse et je lui ajoute 350.
-sinon je garde uniquement le classement du joueur adverse.
Le resulat que j'obtiens je dois l'ajouter a ma base du joueur1 dans performance
Voici mon script PHP
Merci pour vote aide.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 $resultat = mysql_query("SELECT joueur_2.joueur_id AS ID, CONCAT_WS( ' ', joueurs_nom, `joueurs_prenom` ) AS joueur, joueur_2.appariement AS Appariement, inscription.joueurs_classement, joueur_2.point FROM joueur_2, joueurs, inscription WHERE joueur_2.joueur_id = joueurs.joueurs_id AND inscription.joueurs_id = joueur_2.joueur_id AND joueur_2.tournois_id = '".$_GET['tournois']."' AND ronde = '".$_POST['ronde']."' ORDER BY joueur_2.appariement"); while ($row = mysql_fetch_assoc($resultat)) { if ($row[4] == 1) { $resultat2 = mysql_query("SELECT * FROM `joueur_1` where `tournois_id` = '".$_GET['tournois']."' AND ronde = '".$_POST['ronde']."' order by appariement ASC"); while ($row2 = mysql_fetch_assoc($resultat2)) { $resultat3 = mysql_query("UPDATE `joueur_1` SET `Performance` = '".$row[3]."+350' where joueur_id='".$row2['joueur_id']."' AND ronde='".$_POST['ronde']."' AND `tournois_id` = '".$_GET['tournois']."' "); } } else { $resultat2 = mysql_query("SELECT * FROM `joueur_1` where `tournois_id` = '".$_GET['tournois']."' AND ronde = '".$_POST['ronde']."' order by appariement ASC"); while ($row2 = mysql_fetch_assoc($resultat2)) { $resultat3 = mysql_query("UPDATE `joueur_1` SET `Performance` = '".$row[3]."' where joueur_id='".$row2['joueur_id']."' AND ronde='".$_POST['ronde']."' AND `tournois_id` = '".$_GET['tournois']."' "); } } }
Cordialement