dousha1873 2017-03-13 08:22
浏览 38

需要帮助显示数据库中的数据

I have a table[info] like this

+---+-------+---------------+
|id | cost  | place         |
+---+-------+---------------+
|1  | 2000  | Dhaka         | 
|2  | 1000  | Cox's Bazar   |
+---+-------+---------------+

Now I'm using this query to show these data

$a_place = $_POST['place'];
query = "SELECT * FROM info WHERE place = '$a_place'";

It works fine when I am searching for Dhaka, but it is not working for Cox's Bazar. Maybe for this > '

Now what can I do? Please help!

  • 写回答

2条回答 默认 最新

  • duanshang9426 2017-03-13 08:26
    关注

    try this

    $a_place = str_replace($_POST['place'],"'","''");
    
    query = "SELECT * from info WHERE place = '".$a_place."'";
    

    Edit

    creating table and insert data

    enter image description here

    as you see the data ise like yours.

    and If I select like mine the output is true

    enter image description here

    评论

报告相同问题?