สอบถามการสร้างตารางหน่อยค่ะ
อยากให้ข้อมูลที่ช่อง Errors ผสานกันนะค่ะ
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
if ($Qno==1){
echo "Number of Question =".round($row['Possible Points']);
//$NumberOfQuestion = $row["Possible Points"];
} */
$NumberOfQuestion = round($row["Possible Points"]);
for ($Qno=1;$Qno<=$NumberOfQuestion;$Qno++){
$Quiz[$Qno."0"]=$row["PriKey".$Qno];
if ($row["Stu".$Qno]=="A"){
$Quiz[$Qno."1"]=$Quiz[$Qno."1"]+1;
//echo "Quiz".$Qno."1 Keep Value=".$Quiz[$Qno."1"]."<br />";
}
elseif ($row["Stu".$Qno]=="B") {
$Quiz[$Qno."2"]=$Quiz[$Qno."2"]+1;
//echo "Quiz".$Qno."2 Keep Value=".$Quiz[$Qno."2"]."<br />";
}
elseif ($row["Stu".$Qno]=="C"){
$Quiz[$Qno."3"]=$Quiz[$Qno."3"]+1;
//echo "Quiz".$Qno."3 Keep Value=".$Quiz[$Qno."3"]."<br />";
}
elseif ($row["Stu".$Qno]=="D") {
$Quiz[$Qno."4"]=$Quiz[$Qno."4"]+1;
//echo "Quiz".$Qno."4 Keep Value=".$Quiz[$Qno."4"]."<br />";
}
elseif ($row["Stu".$Qno]=="E"){
$Quiz[$Qno."5"]=$Quiz[$Qno."5"]+1;
//echo "Quiz".$Qno."5 Keep Value=".$Quiz[$Qno."5"]."<br />";
}
}
$Q++;
}
echo "<div class=datagrid><table>
<tr>
<th width=10> <div align=center>No</th>
<th width=50> <div align=center>Answer</th>
<th width=80> <div align=center>Correct</th>
<th> <div align=center>Errors</th>
</tr>";
for ($Qno=1;$Qno<=$NumberOfQuestion;$Qno++){
echo
"<tr>
<td align=center>$Qno</td>
<td align=center>".$Quiz[$Qno.'0']."</td>";
$Report = array("A" => $Quiz[$Qno."1"],"B" => $Quiz[$Qno."2"],"C" => $Quiz[$Qno."3"],"D" => $Quiz[$Qno."4"],"E" => $Quiz[$Qno."5"]);
if ($Quiz[$Qno."0"]=="A"){
echo "<td align=center>".round(($Quiz[$Qno."1"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="B"){
echo "<td align=center>".round(($Quiz[$Qno."2"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="C"){
echo "<td align=center>".round(($Quiz[$Qno."3"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="D"){
echo "<td align=center>".round(($Quiz[$Qno."4"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="E"){
echo "<td align=center>".round(($Quiz[$Qno."5"]/$NumberOfStudent*100),2)."%</td> ";
}
arsort($Report);// Sort array value from high to low
foreach ($Report as $key => $val) {
if ($Quiz[$Qno."0"]!=$key && $val!=""){
echo "<td>$key: ".round(($val/$NumberOfStudent*100),2)."%</td>" ;
}
}
echo "<td><br></td></tr>";
}
echo "</table>";
}
else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
if ($Qno==1){
echo "Number of Question =".round($row['Possible Points']);
//$NumberOfQuestion = $row["Possible Points"];
} */
$NumberOfQuestion = round($row["Possible Points"]);
for ($Qno=1;$Qno<=$NumberOfQuestion;$Qno++){
$Quiz[$Qno."0"]=$row["PriKey".$Qno];
if ($row["Stu".$Qno]=="A"){
$Quiz[$Qno."1"]=$Quiz[$Qno."1"]+1;
//echo "Quiz".$Qno."1 Keep Value=".$Quiz[$Qno."1"]."<br />";
}
elseif ($row["Stu".$Qno]=="B") {
$Quiz[$Qno."2"]=$Quiz[$Qno."2"]+1;
//echo "Quiz".$Qno."2 Keep Value=".$Quiz[$Qno."2"]."<br />";
}
elseif ($row["Stu".$Qno]=="C"){
$Quiz[$Qno."3"]=$Quiz[$Qno."3"]+1;
//echo "Quiz".$Qno."3 Keep Value=".$Quiz[$Qno."3"]."<br />";
}
elseif ($row["Stu".$Qno]=="D") {
$Quiz[$Qno."4"]=$Quiz[$Qno."4"]+1;
//echo "Quiz".$Qno."4 Keep Value=".$Quiz[$Qno."4"]."<br />";
}
elseif ($row["Stu".$Qno]=="E"){
$Quiz[$Qno."5"]=$Quiz[$Qno."5"]+1;
//echo "Quiz".$Qno."5 Keep Value=".$Quiz[$Qno."5"]."<br />";
}
}
$Q++;
}
echo "<div class=datagrid><table>
<tr>
<th width=10> <div align=center>No</th>
<th width=50> <div align=center>Answer</th>
<th width=80> <div align=center>Correct</th>
<th> <div align=center>Errors</th>
</tr>";
for ($Qno=1;$Qno<=$NumberOfQuestion;$Qno++){
echo
"<tr>
<td align=center>$Qno</td>
<td align=center>".$Quiz[$Qno.'0']."</td>";
$Report = array("A" => $Quiz[$Qno."1"],"B" => $Quiz[$Qno."2"],"C" => $Quiz[$Qno."3"],"D" => $Quiz[$Qno."4"],"E" => $Quiz[$Qno."5"]);
if ($Quiz[$Qno."0"]=="A"){
echo "<td align=center>".round(($Quiz[$Qno."1"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="B"){
echo "<td align=center>".round(($Quiz[$Qno."2"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="C"){
echo "<td align=center>".round(($Quiz[$Qno."3"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="D"){
echo "<td align=center>".round(($Quiz[$Qno."4"]/$NumberOfStudent*100),2)."%</td>";
}elseif ($Quiz[$Qno."0"]=="E"){
echo "<td align=center>".round(($Quiz[$Qno."5"]/$NumberOfStudent*100),2)."%</td> ";
}
arsort($Report);// Sort array value from high to low
foreach ($Report as $key => $val) {
if ($Quiz[$Qno."0"]!=$key && $val!=""){
echo "<td>$key: ".round(($val/$NumberOfStudent*100),2)."%</td>" ;
}
}
echo "<td><br></td></tr>";
}
echo "</table>";
}
else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>
x ใส่ตัวเลขที่ต้องการครับ เช่น 2 หมายถึง td นี้จะกว้าง 2 คอลัมน์