0

我想请教这里的前辈。我可以只显示 1 个 ID 吗?

当我单击第一行的查看时。我只想显示第一行。

+----+--------------+-------------+----------+---------+-----------------+---------------+-----------+---------------------+-----------+---------------+--------+------+--------+
| 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 |
+----+--------------+-------------+----------+---------+-----------------+---------------+-----------+---------------------+-----------+---------------+--------+------+--------+

但是,在我首先单击查看后,我得到了这个。

----------------------------------------------------------- 
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>";

              }

有什么建议吗?

4

1 回答 1

0

更改您的查询以包含用户 ID

"SELECT * FROM pinjaman where id = ".intval(mysql_real_escape_string($id));
于 2013-03-10T18:04:50.630 回答