2017-09-16 49 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 –