我如何将数据显示到循环输入字段?

时间:2014-10-06 18:45:55

标签: php mysql html5 mysqli

我正在尝试为我的测验生成器生成结果。我的测验生成器有不同的类别,我想在每个类别中显示单独的结果。为了显示结果/分数,我循环了类别并将其作为输入类型=按钮。我按钮的数据来自 tbl_category

SRPerCat.php

<?php
session_start();
?>
<?php 
$con=mysqli_connect("localhost","root","admin","learning_assessment") or die("cannot connect to database!");
$sqlcat="select * from tbl_category;";
$rscat=mysqli_query($con,$sqlcat);
$rowscat=mysqli_fetch_array($rscat);
?>

<form action="SRPerCat.php" method="post">

<?php do{?>
<table border="1">
<tr>

<th><input class="submitbtnsSTARTEXAM" type="submit" name="categories" value="<?php echo $rowscat['category'];?>" /></th>

<th><input type="text" name="scores" value="/*What to put here???*/" /></th>
</tr>
</table>

<?php }while($rowscat=mysqli_fetch_array($rscat));?>
<br /><br /><input class="submitbtnsSTARTEXAM" type="submit" name="sendmyscore" value="VIEW MY SCORE PER AREA" />
</form>

我想要发生的是,当我单击按钮(单独)[例如:按钮的值是“数学”]时,它会在旁边的文本字段中显示获得的分数($ _ POST ['scores' ]

这是我的查询,分数来自哪里。 分数将来自 tbl_corrects

if(isset($_POST['categories'])){
$countcat="select * from tbl_corrects where category='$_POST[categories]' and correctorwrong='CORRECT' and username='$_SESSION[user]';";
$countcatrs=mysqli_query($con,$countcat);
$countcatrows=mysqli_num_rows($countcatrs);
echo $countcatrows;
}
?>

$ countcatrows是我想要在提交按钮旁边的文本字段中显示的值(带有类别的值)。

就像,当我单击按钮(逐个)时,分数将出现在每个类别(按钮)旁边。

0 个答案:

没有答案