duanba8173 2015-03-03 12:45
浏览 24
已采纳

连接功能与PHP中的按钮

I have function to select all the data in my database with SELECT, and also made a form where I create a button for searching data in database by name, last name and id number, but I cant connect the button with my function to show me the data that I am searching for.

I think that I must create a event on button to show me the searched data.

I will show you my code for function:

public function findData ($id,$table){

    $sql = "SELECT `name`, `lastname`, `id_number` FROM `members`
    WHERE `name` LIKE '%".$word."%'
    OR `lastname` LIKE '%".$word."%'
    OR `id_number` LIKE '%".$word."%';";
    $q     = $this->conn->query($sql) or die("failed!");
    while($r = $q->fetch(PDO::FETCH_ASSOC)){
        $data[]=$r;
    }
}

And here I declare

 if(isset($_GET['find_id'])){
if($obj->findData($_GET['find_id'],"members"))

Please help me what to do to connect the function the button

This is my form

<form action="user.php" method="get">
<h4>Име</h4> <textarea cols="10" rows="1" name="find_id"></textarea>
  <h4>Презиме <h4> <textarea cols="10" rows="1" name="find_id"></textarea>
  <h4>Матичен број <h4> <textarea cols="10" rows="1" name="find_id"></textarea>
 <input type="submit" value="Submit"  name="find_id"></form>
  • 写回答

1条回答 默认 最新

  • duanjianshen4871 2015-03-03 12:54
    关注

    Please try this

       if(isset($_GET['find_id'])){
         //call your function here 
          }
    

    Your HTML file

      <form action="connect.php" method="get">
     <input type="submit" value="Submit"      name="find_id"></form>
    

    Or use jQuery using ajax .

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于php中URL传递GET全局变量的问题
  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件