dongyan8929 2018-01-31 17:34
浏览 43

PHP搜索栏导致页面加载错误

I had a page loading data from my mysql database working and showing the data correctly, but after attempting to implement a search function there is now an error attempting to load the page.

Below is my html code I added for the search bar (this is in the file PhysicianSearch.php):

<form action="PhysicianSearch.php" method="post">
  <input type="text" placeholder="Search.." name="ValueToSearch">
  <input type="submit" name="search" value="Filter"><br><br>
</form>

below is the php code I added for the search bar (this is in the file PhysicianSearch.php):

<?php
  if(isset($_POST['search'])) {
      $valueToSearch = $_POST['valueToSearch'];
      $query = "SELECT * FROM Physician WHERE CONCAT('physicianID', 'firstName', 'lastName', 'yearNum', 'yearNum', 'position', 'isAttending', 'highRiskTrained') LIKE '%" . $valueToSearch ."%'";
      $search_result = filterTable($query);

  } else {
    $query = "select * from Physician";
    $search_result = filterTable($query);

  }

  function filterTable($query) {
    $connect = mysqli_connect("localhost", "root", "password", "dbName");
    $filter_results = mysqli_query($connect, $query);
    return $filter_results

  }
?>
  • 写回答

1条回答 默认 最新

  • douziqian2871 2018-01-31 17:37
    关注

    Your input name is ValueToSearch where the PHP code is checking for valueToSearch

    Make sure they have the same case

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制