不顯示我需要help.i有這個數據庫數據庫並使用GET方法
student_code: 1234
student_id: angel
namaFoto: angel.jpg
使用GET method
從數據庫中調用特定的數據,我用這個代碼以下,但數據並沒有顯示出來。我做錯了什麼?
<?php
include_once "library/inc.sesadmin.php";
$row \t = 25;
$hal \t = isset($_GET['hal']) ? $_GET['hal'] : 1;
if($usertype != 'Admission'||$usertype != 'Administrator'){
if($_GET) {
\t $Kode \t = $_GET['Kode'];
\t $myQry=$db->prepare("SELECT * FROM student WHERE student_code='$Kode'");
\t $myQry->execute();
$myQryCount = $myQry->rowCount();
\t while ($myData = $myQry->fetch()) {
\t }
}
?>
<table >
<tr>
<td ><img src="foto/<?php echo $namaFoto; ?>"></td>
<td ><b>Code</b></td>
<td ><b>:</b></td>
<td ><?php echo $myData['student_code']; ?></td>
</tr>
<tr>
<td><b>Student ID </b></td>
<td><b>:</b></td>
<td> <?php echo $myData['student_id']; ?> </td>
</tr>
</table>
<?php } else { ?>
<br /> <br /> <br /> <br /> <br /> <br />
<p align="center">You are not authorized to access this area</p>
<?php } ?>
**警告**:由於在查詢中使用了用戶數據,因此存在一些嚴重的[SQL注入漏洞](http://bobby-tables.com/)。儘可能使用**準備好的陳述**。這些在['mysqli'](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)和[PDO](http://php.net/manual/)中很簡單en/pdo.prepared-statements.php)其中任何用戶提供的數據都是用'?'或':name'指示符指定的,後者使用'bind_param'或'execute'填充,具體取決於您使用的是哪一個。 **絕不**將'$ _POST','$ _GET'或任何用戶數據直接放入您的查詢中。 – tadman
get變量是否來自html表單或URL?同時檢查它是否爲空 – Akintunde007
您可能有SQL錯誤,或者您可能沒有運行您認爲自己的查詢。 – tadman