2
Goodmorning guys!在這裏,我想要做的,我想總結兩列,units_lab
和units_lec
,但是當我在桌子下面運行我的代碼變得凌亂。這個問題的原因是什麼?我的方法來總結列是錯誤的?這是什麼正確的方法?總結提取的數據
if(isset($_POST['loadsgrade'])){
$stud = $_POST['stud'];
$output = '';
$sql = "SELECT * FROM grades WHERE stud_no ='$stud'";
$result = mysqli_query($con,$sql);
$output .= '
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th>Subject Code</th>
<th>Section</th>
<th>Subject Decription</th>
<th>Units</th>
<th width="50">Prelim</th>
<th width="50">Midterm</th>
<th width="50">Finals</th>
<th width="100">Final Grade</th>
</tr>';
while($row = mysqli_fetch_array($result))
{
$output .= '<tr>
<td>'.$row['subj_cd'].'</td>
<td>'.$row['section'].'</td>
<td>'.$row['subj_descr'].'</td>
<td>'.$row['units_lec'] + $row['units_lab'].'</td>
<td>'.$row['prelim_grade'].'</td>
<td>'.$row['midterm_grade'].'</td>
<td>'.$row['finals_grade'].'</td>
<td>'.$row['final_grade'].'</td>
</tr>
';
}
$output .= '</table>
</div>';
echo $output;
}
'桌子變得凌亂。「你的意思是?你是否可以包含SS –
你已經開放SQL注入。使用參數化查詢。你也可以在mysql中添加2個值。等待「混亂」的定義。 – chris85
@Nishanth Matha和chriss85,我編輯我的問題並添加了SS。看一看。但下面的答案已經解決了它。 – nethken