如何只显示请求ID?

时间:2013-03-10 18:01:27

标签: php

我想在这里问大四。我只能显示1个身份证吗?

当我点击第一行的查看时。我只希望显示第一行。

+----+--------------+-------------+----------+---------+-----------------+---------------+-----------+---------------------+-----------+---------------+--------+------+--------+
| Id | username     | Peralatan   | Kuantiti | Tujuan  | Tarikh Pinjaman | Tarikh Pulang | Masa Guna |  Masa Terima        | Keputusan | KuantitiLulus | Respon | View | Delete |
+----+--------------+-------------+----------+---------+-----------------+---------------+-----------+---------------------+-----------+---------------+--------+------+--------+
| 31 | FahmiNazirul | Speaker     | 12       | testing | 10/03/2013      | 11/03/201     | 12 pagi   | 10/03/2013 07:35:40 | Lulus     |  2            | Respon | View | Delete |
+----+--------------+-------------+----------+---------+-----------------+---------------+-----------+---------------------+-----------+---------------+--------+------+--------+
| 35 | ali          |Lcd_projecter|  1       | testing | 10/03/2013      |  11/03/2013   | 12 pagi   | 10/03/2013 02:54:55 | Lulus     |  1            | Respon | View | Delete |
+----+--------------+-------------+----------+---------+-----------------+---------------+-----------+---------------------+-----------+---------------+--------+------+--------+

但是,在我点击View之后,我明白了。

----------------------------------------------------------- 
Username: FahmiNazirul
Peralatan: Speaker
Kuantiti: 12
Tarikh Pinjam: 10/03/2013
Tarikh Pulang: 11/03/2013
Masa untuk di ambil: 12 pagi
----------------------------------------------------------- 
Kepututsan: Lulus
Kuantiti yang di luluskan: 2
----------------------------------------------------------- 


----------------------------------------------------------- 
Username: ali
Peralatan: Lcd_projecter
Kuantiti: 1
Tarikh Pinjam: 10/03/2013
Tarikh Pulang: 11/03/2013
Masa untuk di ambil: 12 pagi
----------------------------------------------------------- 
Kepututsan: Lulus
Kuantiti yang di luluskan: 1
----------------------------------------------------------- 

我的编码显示上面的数据

$id =$_REQUEST['Id'];

            $query = "SELECT * FROM pinjaman ";

            $result = mysql_query($query) or die(mysql_error()) ;

            while(($row = mysql_fetch_array($result)))

              {

              $id = $row['Id'];
              echo "----------------------------------------------------------- " ."<br/>";
              echo " Username: " . $row['username'] ."<br/>";
              echo " Peralatan: " . $row['BarangPinjaman']."<br/>" ;
              echo " Kuantiti: " . $row['Kuantiti']."<br/>" ;                 
              echo " Tarikh Pinjam: " . $row['tarikhpinjam'] ."<br/>";
              echo " Tarikh Pulang: " . $row['tarikhpulang']."<br/>";
              echo " Masa untuk di ambil: " . $row['masaguna']."<br/>";
              echo "----------------------------------------------------------- " ."<br/>";
              echo " Kepututsan: " . $row['keputusan']."<br/>";
              echo " Kuantiti yang di luluskan: ". $row['kuantitilulus']."<br/>";
              echo "----------------------------------------------------------- " ."<br/>";


              echo "</tr>";

              }

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

将您的查询更改为包含用户ID

"SELECT * FROM pinjaman where id = ".intval(mysql_real_escape_string($id));