Affichage de questions php/mysql
Résolu
squid3570
Messages postés
19
Date d'inscription
Statut
Membre
Dernière intervention
-
squid3570 Messages postés 19 Date d'inscription Statut Membre Dernière intervention -
squid3570 Messages postés 19 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j ai besoin d aide en php.J ai un site ou les eleves doivent se connecte.A chque connections,ils doivent choisir un matiere et cela devra afficher 20 questions parmi 1000 de facon aleatoire avec des boutons radios.les boutons s affichent sans les questions.Voici mon code :
<body>
<table width="950">
<tr>
<td> </td>
</tr>
</table>
<table class="maint">
<tr>
<td colspan="100%" height="450">
<form id="form1" name="form1" method="post" action="examsResults.php"><table width="100%" height="1405" border="0" cellpadding="3" cellspacing="0">
<?php
$server_conn = mysql_connect("localhost", "root", "");
$select_db = mysql_select_db("qpeople", $server_conn);
if (!$select_db)
{return false;}
$query = "SELECT * FROM english ORDER BY RAND() LIMIT 10";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_row($result)){
$i=$row;
//for($i = 0; $i <10; $i++)
?>
<tr>
<td height="20" bgcolor="#A35252"><p style="color:#FFFFFF">Question <?php echo $i ?> </p></td>
</tr>
<tr>
<td height="60" align="left" valign="top"> <?php echo $rs[$i]['FQUESTIONS'];?> </td>
</tr>
<tr>
<td height="140" align="left" valign="top"><p>
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="A" />
<?php echo $rs[$i]['FANSWER_A'];?></label>
<br />
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="B" />
<?php echo $rs[$i]['FANSWER_B'];?></label>
<br />
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="C" />
<?php echo $rs[$i]['FANSWER_C'];?></label>
<br />
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="D" />
<?php echo $rs[$i]['FANSWER_D'];?></label>
<br />
</p></td>
</tr>
<?php } ?>
<tr>
</tr>
<tr>
<td height="10" align="center"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form></td>
<td width="15%" height="1405" align="left" valign="top"><div id="RMarginDiv"></div></td>
</tr>
</table>
</div></td>
<td width="12%"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="100%">
<div id="bbar">
<center>|<a href="../index.html" class="bbar">Home</a>|<a href="../about.htm" class="bbar">About Us</a>|<a href="../register.htm" class="bbar">Register</a>
|<a href="../info.htm" class="bbar">Contact Info</a>|<br>
©.</center>
</div>
</td>
</tr>
</table>
</body>
j ai besoin d aide en php.J ai un site ou les eleves doivent se connecte.A chque connections,ils doivent choisir un matiere et cela devra afficher 20 questions parmi 1000 de facon aleatoire avec des boutons radios.les boutons s affichent sans les questions.Voici mon code :
<body>
<table width="950">
<tr>
<td> </td>
</tr>
</table>
<table class="maint">
<tr>
<td colspan="100%" height="450">
<form id="form1" name="form1" method="post" action="examsResults.php"><table width="100%" height="1405" border="0" cellpadding="3" cellspacing="0">
<?php
$server_conn = mysql_connect("localhost", "root", "");
$select_db = mysql_select_db("qpeople", $server_conn);
if (!$select_db)
{return false;}
$query = "SELECT * FROM english ORDER BY RAND() LIMIT 10";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_row($result)){
$i=$row;
//for($i = 0; $i <10; $i++)
?>
<tr>
<td height="20" bgcolor="#A35252"><p style="color:#FFFFFF">Question <?php echo $i ?> </p></td>
</tr>
<tr>
<td height="60" align="left" valign="top"> <?php echo $rs[$i]['FQUESTIONS'];?> </td>
</tr>
<tr>
<td height="140" align="left" valign="top"><p>
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="A" />
<?php echo $rs[$i]['FANSWER_A'];?></label>
<br />
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="B" />
<?php echo $rs[$i]['FANSWER_B'];?></label>
<br />
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="C" />
<?php echo $rs[$i]['FANSWER_C'];?></label>
<br />
<label>
<input type="radio" name="<?php echo "RadioGroup".$i;?>" value="D" />
<?php echo $rs[$i]['FANSWER_D'];?></label>
<br />
</p></td>
</tr>
<?php } ?>
<tr>
</tr>
<tr>
<td height="10" align="center"><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form></td>
<td width="15%" height="1405" align="left" valign="top"><div id="RMarginDiv"></div></td>
</tr>
</table>
</div></td>
<td width="12%"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="100%">
<div id="bbar">
<center>|<a href="../index.html" class="bbar">Home</a>|<a href="../about.htm" class="bbar">About Us</a>|<a href="../register.htm" class="bbar">Register</a>
|<a href="../info.htm" class="bbar">Contact Info</a>|<br>
©.</center>
</div>
</td>
</tr>
</table>
</body>
A voir également:
- Affichage de questions php/mysql
- Affichage double ecran - Guide
- Easy php - Télécharger - Divers Web & Internet
- Windows 11 affichage classique - Guide
- Mysql community server - Télécharger - Bases de données
- Problème affichage fenêtre windows 10 - Guide
2 réponses
Bonsoir,
essayes plutot avec mysql_fetch_array(
et d'ou venaient les $rs ??
je suppose que les noms des champs de ta tables sont: 'FQUESTIONS' etc...
@lain
essayes plutot avec mysql_fetch_array(
et d'ou venaient les $rs ??
je suppose que les noms des champs de ta tables sont: 'FQUESTIONS' etc...
<body> <table width="950"> <tr> <td> </td> </tr> </table> <table class="maint"> <tr> <td colspan="100%" height="450"> <form id="form1" name="form1" method="post" action="examsResults.php"> <table width="100%" height="1405" border="0" cellpadding="3" cellspacing="0"> <?php $server_conn = mysql_connect("localhost", "root", ""); $select_db = mysql_select_db("qpeople", $server_conn) or die (mysql_error()); $query = "SELECT * FROM english ORDER BY RAND() LIMIT 10"; $result = mysql_query($query) or die(mysql_error()); $i=1; while($ligne = mysql_fetch_array($result)){ ?> <tr> <td height="20" bgcolor="#A35252"><p style="color:#FFFFFF">Question <?php echo $i ?> </p></td> </tr> <tr> <td height="60" align="left" valign="top"> <?php echo $ligne['FQUESTIONS'];?> </td> </tr> <tr> <td height="140" align="left" valign="top"><p> <label> <input type="radio" name="<?php echo "RadioGroup".$i;?>" value="A" /> <?php echo $ligne['FANSWER_A'];?></label> <br /> <label> <input type="radio" name="<?php echo "RadioGroup".$i;?>" value="B" /> <?php echo $ligne['FANSWER_B'];?></label> <br /> <label> <input type="radio" name="<?php echo "RadioGroup".$i;?>" value="C" /> <?php echo $ligne['FANSWER_C'];?></label> <br /> <label> <input type="radio" name="<?php echo "RadioGroup".$i;?>" value="D" /> <?php echo $ligne['FANSWER_D'];?></label> <br /> </p></td> </tr> <?php $i++; } ?> <tr> </tr> <tr> <td height="10" align="center"><input type="submit" name="Submit" value="Submit" /></td> </tr> </table> </form></td> <td width="15%" height="1405" align="left" valign="top"><div id="RMarginDiv"></div></td> </tr> </table> </div></td> <td width="12%"> </td> </tr> </table> </td> </tr> <tr> <td colspan="100%"> <div id="bbar"> <center>|<a href="../index.html" class="bbar">Home</a>|<a href="../about.htm" class="bbar">About Us</a>|<a href="../register.htm" class="bbar">Register</a> |<a href="../info.htm" class="bbar">Contact Info</a>|<br> ©.</center> </div> </td> </tr> </table> </body>
@lain