Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php mysql中显示来自多个表的唯一数据_Php_Mysql - Fatal编程技术网

如何在php mysql中显示来自多个表的唯一数据

如何在php mysql中显示来自多个表的唯一数据,php,mysql,Php,Mysql,我有三种不同的数据要通过php显示,如下所示 我需要显示数据,如下图所示。 但是当我使用foreach循环来显示它们时,结果如下 foreach($GetSectionWiseExpected作为$gsa){ foreach($GetSectionwiseCorrect为$gsc){ foreach($GetSectionwiseTimeSpent作为$gst){ $markp_q=''; $penaltyp_q=''; $full_马克=“”; $correct_ans=$gsc['corr

我有三种不同的数据要通过php显示,如下所示

我需要显示数据,如下图所示。 但是当我使用foreach循环来显示它们时,结果如下

foreach($GetSectionWiseExpected作为$gsa){
foreach($GetSectionwiseCorrect为$gsc){
foreach($GetSectionwiseTimeSpent作为$gst){
$markp_q='';
$penaltyp_q='';
$full_马克=“”;
$correct_ans=$gsc['correct'];
$total_trunt=$gsa['total_trunt'];
$SC_DETAILS=showSub_CourseDetails($paperID);
foreach($SC_详细信息为$SC){
$markp_q=$sc['markp_q'];
$penaltyp_q=$sc['penaltyp_q'];
$full_mark=$sc['full_mark'];
}
$error\u ans=$total\u trunt-$correct\u ans;
$marks_got=($correct_ans*$markp_q)-($error_ans*$penaltyp_q);
?>

请添加到目前为止您尝试过的代码,而不是图像。您可以使用连接,但首先告诉您实际要从表中获取的内容。在每个for循环中,一个数据是公共的,第二列数据是唯一的,我需要在循环中使用公共数据显示唯一的数据,但在我编写上述代码时,相同的数据会多次重复多次
foreach($GetSectionwiseAttempted as $gsa) { 
    foreach($GetSectionwiseCorrect as $gsc) {
        foreach($GetSectionwiseTimeSpent as $gst) { 
            $markp_q = '';
            $penaltyp_q = '';
            $full_mark = '';
            $correct_ans = $gsc['CORRECT'];
            $total_attempt = $gsa['total_attempted'];
            $SC_DETAILS = showSub_CourseDetails($paperID);

            foreach($SC_DETAILS as $sc) {
                $markp_q = $sc['markp_q'];
                $penaltyp_q = $sc['penaltyp_q'];
                $full_mark = $sc['full_mark'];
            }
            $wrong_ans = $total_attempt-$correct_ans;
            $marks_got = ($correct_ans*$markp_q)-($wrong_ans*$penaltyp_q);
            ?>
            <?php echo   $gsa['sub_name'];?>    </font>
            <?php echo $marks_got; ?><?php echo $gsa['total_attempted'];?>
            <?php echo $gsc['CORRECT'];?>
            <?php $last_active = $gst['time_spent'];

            $minutes = floor($last_active / 60);
            $seconds = $last_active % 60;

            if ($minutes > 0) {
                echo $minutes . 'minutes';
            }

            if ($seconds > 0) {
                if ($minutes > 0) {
                    echo "and ";
                }
                echo $seconds . 'seconds';
            }
        }
    }
} 
?>