0
2つの配列をマージしてhtmlの のデータを印刷するか、データを直接印刷する必要がありますが、コードでは重複したデータが印刷されます。2つの配列をマージしてhtmlでデータを印刷する
これは、配列では、データベースから来る:
Array
(
[Course name] => English 4A
[Grade out of weight exam] => 47.25
)
Array
(
[Course name] => Humanities 4A
[Grade out of weight exam] => 45.00
)
Array
(
[FullName] => Adam Sherif Wahba Ibrahim Botros
[Course name] => English 4A
[Grade name] => 2nd Term
[Grade] => 74.25
[MAX] => 100.00
[Percentage] => 74.25
[Grade out of weight] => 247.50
[gi.aggregationcoef*100] => 333.33300
)
Array
(
[FullName] => Adam Sherif Wahba Ibrahim Botros
[Course name] => Humanities 4A
[Grade name] => 2nd Term
[Grade] => 73.20
[MAX] => 100.00
[Percentage] => 73.20
[Grade out of weight] => 244.00
[gi.aggregationcoef*100] => 333.33000
)
これは私のhtmlコードとPHP
<table border='1'>
<tr class="tr">
<th class="th"> subject </th>
<th class="th"> student's Work out of </th>
<th class="th"> exam out of </th>
<th class="th"> total out of </th>
<th class="th"> Grade </th>
</tr>
<?php
$sql = "SELECT
c.fullname AS'Course name' ,
ROUND(ROUND(gg.finalgrade/gg.rawgrademax * 100 ,2) *(gi.aggregationcoef*100)/100,2) AS 'Grade out of weight exam'
FROM
mdl_course AS c
JOIN mdl_grade_items AS gi ON gi.courseid = c.id
JOIN mdl_grade_grades AS gg ON gg.itemid = gi.id
JOIN mdl_user AS u ON u.id = gg.userid
WHERE gi.courseid = c.id AND gi.itemname in ('2nd Term EXAM')
AND gi.itemtype = 'Category' and u.id = '5'";
$result = $conn->query($sql);
while($row = $result->fetch_assoc())
{
extract($row);
echo '<pre>';
print_r($row) ;
echo '</pre>';
}
///////////////// second SQL Get 2nd term
$sql2 = "SELECT
CONCAT(firstname, ' ', lastname) AS FullName , c.fullname AS'Course name' , gi.itemname AS 'Grade name',
ROUND(gg.finalgrade,2) AS Grade
,ROUND(gg.rawgrademax,2) AS MAX, ROUND(gg.finalgrade/gg.rawgrademax * 100 ,2) AS Percentage
,ROUND(ROUND(gg.finalgrade/gg.rawgrademax * 100 ,2) *(gi.aggregationcoef*100)/100,2) AS 'Grade out of weight'
,gi.aggregationcoef*100
FROM
mdl_course AS c
JOIN mdl_grade_items AS gi ON gi.courseid = c.id
JOIN mdl_grade_grades AS gg ON gg.itemid = gi.id
JOIN mdl_user AS u ON u.id = gg.userid
WHERE gi.courseid = c.id AND gi.itemname in ('2nd Term')
AND gi.itemtype = 'Category' and u.id = '5'"
;
$result2 = $conn->query($sql2);
while($row2 = $result2->fetch_assoc())
{
extract($row2);
echo '<pre>';
print_r($row2) ;
echo '</pre>';
?>
<tr class="tr">
<td class="td"><?php echo $row2["Course name"]; ?></td>
<td class="td"><?php echo ($row2["Grade out of weight"] - $row["Grade out of weight exam"]); ?></td>
<td class="td"><?php echo $row["Grade out of weight exam"]; ?></td>
<td class="td"><?php echo $row2["Grade out of weight"]; ?></td>
<td class="td"><?php echo $row[""]; ?></td>
<?php
}
?>
<td class="td"> </td>
</tr>
</table>
マージ=>、マージけん引=> 2、正しいとあなたの質問は、plsは更新され。 –
あなたの質問を編集してください。あなたのコードは読めません。 –