2017-09-16 89 views
0

不顯示我需要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 } ?>

+0

**警告**:由於在查詢中使用了用戶數據,因此存在一些嚴重的[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

+0

get變量是否來自html表單或URL?同時檢查它是否爲空 – Akintunde007

+0

您可能有SQL錯誤,或者您可能沒有運行您認爲自己的查詢。 – tadman

回答

0

你是否包括?KODE的URL = 1234您正在使用訪問該網頁?此外,圖像不使用相同的$ myData集合來檢索圖像值。這可能不是一個根本原因問題,但看起來確實很大。

+0

是的,我使用href =「?open = Student-Print-Adm & Kode ='。$ row ['student_code']。'」來調用page.how我可以調用圖片嗎? –

+0

你確定這個號碼正在通過Kode嗎?點擊鏈接時,網址是什麼樣的?看起來這個數字沒有被傳遞。 –

+0

這裏是http://something.com/index.php?open=Student-Print-Adm&Kode=1234 –