PHP文件将搜索栏从HTML网页定向到数据库

PHP文件将搜索栏从HTML网页定向到数据库,php,html,Php,Html,我已经在本地机器上创建了HTML网页和搜索栏,并将下载XAMPP以在本地托管它 数据库将位于虚拟机上,并通过虚拟机监控程序播放。我将使用网页和一个搜索栏来查找名称和设备上的8位数字的相关设备,称为资产ID 一位朋友推荐PDO作为数据库的查询语言,那么这会更好吗 注意-数据库尚未运行或连接到。昨天刚拿到作业 HTML 为了做到这一点,您需要生成一个带有的来发送数据,然后将其收集到PHP文件中 HTML: PHP: 逐步教程: 希望能有帮助 <!DOCTYPE html> <ht

我已经在本地机器上创建了HTML网页和搜索栏,并将下载XAMPP以在本地托管它

数据库将位于虚拟机上,并通过虚拟机监控程序播放。我将使用网页和一个搜索栏来查找名称和设备上的8位数字的相关设备,称为资产ID

一位朋友推荐PDO作为数据库的查询语言,那么这会更好吗

注意-数据库尚未运行或连接到。昨天刚拿到作业

HTML


为了做到这一点,您需要生成一个带有的来发送数据,然后将其收集到PHP文件中

HTML:

PHP:

逐步教程:

希望能有帮助

<!DOCTYPE html>
<html>
  <style type="text/css">
                html, body {
                height: 100%;
                margin: 0;
                padding: 0;
                color: #FFFFFFFF;
                }
                img#bg {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                }
                #content {
                position: relative;
                z-index: 1;
                text-align:center;
                }
  </style>
<head>
  <title>Multigress Asset Management</title>
  <!--[if IE 6]>
<style type="text/css">
html { overflow-y: hidden; }
body { overflow-y: auto; }
img#bg { position:absolute; z-index:-1; }
#content { position:static; }
</style>
<![endif]-->
</head>
<body>
    <img src="F:\CAPSTONE PROJECT\background img.jpg" alt="background image" id="bg" />
    <div id="content">
        <h1>Multigress Asset Management</h1>
        <h4>Search by First Name, Last Name, or Asset ID</h4>
        <form action="" method="post">
            <input type="text" name="data">
            <input type="submit" value="Search">
        </form>
        <br />
        <img src="F:\CAPSTONE PROJECT\Logo2.1.png" alt="Multigress Logo 2.1" width="200" height="100">
        <h5>Copyright 2014-2017 | Date Last Updated: 4/27/2015</h5>
        <h5>By viewing this page, you agree to the <A href="terms&conditions.html">Terms & Conditions</A>.</h5>
  </div>
</body>
</html>
<?php
if(isset($_GET['data']) && $_GET['data']=='yes')
{
     echo "<center><font color='red'>Comment Posted!</font></center>";
}
else
{
     echo "<center><font color='red'>Username taken!</font></center>";
}
?>
$con=mysqli_connect("localhost","root","password","dtabasename");

$getUsers = $DBH->prepare("SELECT * FROM TABLE ORDER BY id ASC");
$getUsers->fetchAll();
<form action="submit.php" method="post">
  <input type="text" name="search" />
  <input type="submit" value="Submit" />
</form>
<?php
if(isset($_POST['search']){
  //do database request here
 $db=mysql_connect ("servername",  "<username>", "<password>") or die ('I cannot connect  to the database because: ' . mysql_error()); 
 $sql="SELECT * FROM Search WHERE  FirstName LIKE '%" . $name . "%' OR LastName LIKE '%" . $name  ."%'"; 
}
?>