我想在这里做的是,首先我正在使用juz php和mysql建立一个测验平台,我有一个带有问题ID,qestion,option1,option2,option3,option4和answer的表,所以我想要将问题和选项从mysql传递到单选按钮,并使用结果页面中的输入值
答案 0 :(得分:0)
试试希望它适合你
<script type="text/javascript" src="js/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function(){
$('.table').hide();
});
function next(number){
$('.table').hide();
$('#table'+number).fadeIn(100);
}
</script>
在体内
<?php
$query = mysql_query("SELECT * FROM table_name ORDER BY id");
$i = 1;
while($row = mysql_fetch_array($query)){
?>
<table id="table<?php echo $i; ?>" class="table">
<tbody>
<tr>
<td class="1" id="td01" valign="top" >
<?php echo $row['qestion']; ?>
</td>
</tr>
<tr>
<td id="td1" class="tdradio" valign="top">
<input type="radio" name="option" value="<?php echo $row['option1']; ?>">
</td>
</tr>
<tr>
<td id="td2" class="tdradio" valign="top">
<input type="radio" name="option" value="<?php echo $row['option2']; ?>">
</td>
</tr>
<tr>
<td id="td3" valign="top">
<input type="radio" name="option" value="<?php echo $row['option3']; ?>">
</td>
</tr>
<tr>
<td id="td4" valign="top">
<input type="radio" name="option" value="<?php echo $row['option4']; ?>">
</td>
</tr>
<tr>
<td class="question">
<?php echo $i; $i++; ?>/<?php echo mysql_num_rows($query); ?>
</td>
</tr>
<tr>
<td id="next">
<div class="next" onClick="next(<?php echo $i; ?>);"></div>
</td>
</tr>
</tbody>
</table>
<?php } ?>