par
Elie » 30 déc. 2011, 18:06
Voici la logique mais je te fais pas du clé en main.
3 radio pour 0 N 1 avec comme attribut onclick="updatePronostic(this.name, this.value)" :
Code : Tout sélectionner
<input type="radio" name="match_id_du_match" value="0 ou N ou 1" onclick="updatePronostic(this.name, this.value)" />
Ensuite un creer ta fonction en JS qui va appeller la page qui met a jour les pronostics.
Code : Tout sélectionner
function updatePronostic(id, val) {
// Moi je le fais avec prototypejs.net
new Ajax.Request('updatePronostic.php', {
method: 'get',
parameters: 'id='+id+'&val='+val,
asynchronous: false,
evalScripts: true
}
});
return false;
}
En suite tu te fais ton fichier updatePronostic.php
<?php
$sql = "UPDATE `tbl_pronostic` SET `pronostic_".$_GET['val']."` = pronostic_".$_GET['val']."+1 WHERE `match_id` = ".intval($_GET['id']);
$req = mysql_query($sql) or die(erreurMySQL($sql, mysql_error()));
?>
Dans ma logique j'ai fait une table genre
id_pronostic
match_id
pronostic_0
pronostic_n
pronostic_1
Mais a toi de voir ta logique
Voici la logique mais je te fais pas du clé en main.
3 radio pour 0 N 1 avec comme attribut onclick="updatePronostic(this.name, this.value)" :
[code]<input type="radio" name="match_id_du_match" value="0 ou N ou 1" onclick="updatePronostic(this.name, this.value)" />[/code]
Ensuite un creer ta fonction en JS qui va appeller la page qui met a jour les pronostics.
[code]function updatePronostic(id, val) {
// Moi je le fais avec prototypejs.net
new Ajax.Request('updatePronostic.php', {
method: 'get',
parameters: 'id='+id+'&val='+val,
asynchronous: false,
evalScripts: true
}
});
return false;
} [/code]
En suite tu te fais ton fichier updatePronostic.php
[php]<?php
$sql = "UPDATE `tbl_pronostic` SET `pronostic_".$_GET['val']."` = pronostic_".$_GET['val']."+1 WHERE `match_id` = ".intval($_GET['id']);
$req = mysql_query($sql) or die(erreurMySQL($sql, mysql_error()));
?>[/php]
Dans ma logique j'ai fait une table genre
id_pronostic
match_id
pronostic_0
pronostic_n
pronostic_1
Mais a toi de voir ta logique