是我的html代碼和PHP函數是這樣的,我可以查詢所有問題從數據庫與php mysql_fetch_assoc但不能計算真正的或空的,有效的答案與PHP if(isset($ _ POST function 。我不知道該怎麼做,如果isset功能以及如何計算所有的答案單選按鈕,如果isset功能不工作
<html lang="tr_TR">
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<form action="" method=POST>
<?PHP
require_once('a/baglanti.php');
$sql = "SELECT id as id, soru,a,b,c,d,dcevap,tarih,sorugrup FROM sorular
WHERE yayinla = 'Evet' order by tarih ";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
$id=$row['id'];
$soru=$row['soru'];
$a=$row['a'];
$b=$row['b'];
$c=$row['c'];
$d=$row['d'];
$dcevap=$row['dcevap'];
$sorugrup=$row['sorugrup'];
//all records
?>
<?php echo "$id"; ?> <?php echo "$soru"; ?>
<p><?php echo "$a"; ?> <input type="radio" name="<?php echo "$sorugrup"; ?>" value="a"></p>
<p><?php echo "$b"; ?> <input type="radio" name="<?php echo "$sorugrup"; ?>" value="b"></p>
<p><?php echo "$c"; ?> <input type="radio" name="<?php echo "$sorugrup"; ?>" value="c"></p>
<p><?php echo "$d"; ?> <input type="radio" name="<?php echo "$sorugrup"; ?>" value="d"></p>
<?php
}
mysql_free_result($result);
?>
<p></p>
<p></p>
<input type="submit" value="HESAPLA" name="btn"><br>
</p>
</form>
<?php
if (isset($_POST['$sorugrup'])) {
$soru1=$_POST['$sorugrup'];
$d=0;
$y=0;
\t \t \t
\t \t \t $b=0;
\t \t \t
if($soru1=="$dcevap"){
$c1="DOĞRU";
$d=$d+1;
}
\t \t \t
\t \t \t elseif(empty($soru1)){
\t \t \t \t
\t \t \t \t $c1="boş";
$b=$b+1;
\t \t \t \t
\t \t \t \t }
\t \t \t
\t \t \t
\t \t \t else {
$c1="YANLIŞ";
$y=$y+1;
}
$d2=$d-1;
\t \t \t $puan=$d*3.3;
echo"Doğru sayısı=$d<br>";
echo"Yanlış sayısı=$y<br>";
\t \t \t
\t \t \t echo"Boş sayısı=$b<br>";
\t \t \t
\t \t \t echo"Aldığınız Puan $puan<br>";
}
?>
</body>
</html>