Bonjour

j'ai un système de sondage qui fonctionne plutôt bien, le seul soucis que je rencontre c'est lorsque je cré plusieurs sondages j'ai toujours le même qui apparait lorsque je veux répondre !

J'arrive pas a récupéré l'id du sondage afin de faire un lien vers la page de réponse !

Pour l'affichage public des sondages j'ai ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<?php
//-----------------------------------------------------------------------------
function get_sondage($sondID) {
	global $tab1, $tab2, $ima;
	$result = mysql_query("select * from sondage_admin where sondID = $sondID");
	$number = mysql_num_rows($result);
	if($number != 0) {					
		$row = mysql_fetch_object($result);	
		$sondID = $row->sondID;
		$question = $row->question;
		$nbVotants = $row->nbVotants;
 
		echo "<b>$question</b><br><br>";
		$result = mysql_query("select * from sondage_data where sondID = $sondID");
		if($nbVotants != 0) {
			echo "<table>";
			while($row = mysql_fetch_array($result)) {
				$sondID = $row['sondID'];
				$optionText = $row["optionText"];
				$optionNB = $row["optionNB"]; 
				$pourcent = round($optionNB * 100 / $nbVotants);
				echo "<tr><td>$optionText: <img src='images/sondage.gif' width=$pourcent height=11></td><td> $pourcent % [ $optionNB ]</td></tr>";
			}
			echo "</table>";			
		} 
		echo "<p>Nombre de votants: $nbVotants</p><br>";
	}
	mysql_free_result($result);
}
//-----------------------------------------------------------------------------
$result = mysql_query("select sondID from sondage_admin order by sondID desc");
$number = mysql_num_rows($result);
if ($number == 0) {
	echo"<p align=center>Aucun sondage trouvé !</p>"; 
}
else {						
	$row = mysql_fetch_object($result);	
	$sondID = $row->sondID; // id du sondage en cours
	mysql_free_result($result);
	if ($id == 1) { // Enregistrement de la réponse
			mysql_query("update sondage_data set optionNB=optionNB+1 where sondID = $sondID AND optionID = $vote");
			mysql_query("update sondage_admin set nbVotants=nbVotants+1 where sondID = $sondID");
	}
	while($sondID != 0) { // Affichage des sondages
		echo '<p>[ <a href="sondage_repondre.php?id='.$sondID.'">REPONDRE AU SONDAGE</a> ]</p>';
		get_sondage($sondID);
		$sondID--;
	}
}
?>
ensuite la page pour répondre :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<h2 align="center">Sondage</h2>
<?php
$result	= mysql_query("select sondID,question from sondage_admin order by sondID desc LIMIT 1");
$number	= mysql_num_rows($result);
if ($number	== 0) {
?>
	<p	align=center>Aucun sondage trouvé !</p>
<?php
}
else {
	$row = mysql_fetch_object($result);
	$question =	$row->question;
	$sondID	= $row->sondID;
	mysql_free_result($result);
?>
	<p><?php echo $question;?></font></p>
	<div align=center>
	<table border='0' cellpadding='0' cellspacing='0'	width='230'>
		<form action='sondage.php?id=<?php echo $sondID;?>' method='post'>
			<tr>
				<td	align=right	bgcolor='FFFFFF'><font color='000000' size='2'>
<?php
				$result	= mysql_query("select optionText, optionID from	sondage_data where sondID = '$sondID'");
				while($go =	mysql_fetch_array($result)) {
					$optionText	= $go["optionText"];
					$optionID =	$go["optionID"];
					if($optionText != "") {
?>
						<?php echo $optionText;?><input	type='radio' name='vote' value='<?php echo $optionID;?>'><br>
<?php						
					}
				}
?>				
				</td>
				<td>
					<p><input type='submit' value='Voter'></p>
				</td>
			</tr>
		</form>
	</table>
	</div>
	<p>[ <a href="sondage.php">RETOUR AUX RESULTATS</a> ]</p>
<?php	
}
mysql_free_result($result);
?>
Je ne pense pas que la page de création des sondages soit importante par rapport a mon soucis par contre voiçi les tables utilisé :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
CREATE TABLE IF NOT EXISTS `sondage_admin` (
  `sondID` int(10) NOT NULL auto_increment,
  `question` char(100) NOT NULL,
  `nbVotants` int(10) NOT NULL default '0',
  PRIMARY KEY  (`sondID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
CREATE TABLE IF NOT EXISTS `sondage_data` (
  `sondID` int(11) NOT NULL default '0',
  `optionText` char(50) NOT NULL,
  `optionID` int(11) NOT NULL default '0',
  `optionNB` int(11) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Merci