Php 搜索引擎代码错误

Php 搜索引擎代码错误,php,html,mysql,ajax,Php,Html,Mysql,Ajax,我希望在搜索引擎方面得到一些帮助,我正在努力写作 到目前为止,我有两个.php文件,一个是index.php,另一个是search.phpindex.php是一个前端网站,用户在其中输入他们想要搜索的内容,搜索结果应该显示在哪里。然而,我认为我的代码不起作用,当我试图执行搜索时,我在搜索栏下面得到了很多我写的代码 代码如下: index.php <!DOCTYPE html PUBLIC "-//W3C??DTD XHTML 1.0 Transitional//EN" http://www

我希望在搜索引擎方面得到一些帮助,我正在努力写作 到目前为止,我有两个
.php
文件,一个是
index.php
,另一个是
search.php
index.php
是一个前端网站,用户在其中输入他们想要搜索的内容,搜索结果应该显示在哪里。然而,我认为我的代码不起作用,当我试图执行搜索时,我在搜索栏下面得到了很多我写的代码

代码如下: index.php

<!DOCTYPE html PUBLIC "-//W3C??DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xxhtmll/DTD/xhtmll-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
    <meta http-eqiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Trial Report Database - Home</title>
</head>
<body>
    <center>
    <h2>CIS TDU Trial Report</h2>
    <form action='./search.php' method='get'>
    <input type='text' name='k' size='100' />
    <input type='submit' value='Search'>
    </form>
    </center>
</body>
</html>

试验报告数据库-搜索
CIS TDU试验报告


你的代码中有很多错误。您应该先从一些教程网站了解更多信息。e、 首先,非常基本的一件事,为什么每个页面上都有两个html标记看到错误iv改变了它,你应该使用search.php文件中的(isset($_GET['k])条件并检查数据库连接,你在哪里创建这个。请检查教程网站,然后再做任何工作。
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xxhtmll/DTD/xhtmll-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
    <meta http-eqiv="Content-Type" content="text/html; charset=utf-8" />
    <title> Trial Report Database - Search</title>
</head>
<body>

    <center>
    <h2>CIS TDU Trial Report</h2>

    <form action='./search.php' method='get'>
        <input type='text' name='k' size='100' placeholder='Enter Trial Here...' />
        <input type='submit' value='Search' /> 
    </form>
    </center>

    <hr />
    <?php
        $k = $_GET['k'];
        $terms = explode("", $k);
        $query = "SELECT * FROM cistdutrd WHERE keywords='$term1'" 

        foreach ($terms as $each){
            $i++;

            if ($i == 1)            
                $query .= "keywords LIKE '%$each%'";
            else 
                $query .= "OR keywords LIKE '%$each%'";
    }

    echo $query

    //collect
    mysql_connect("localhost", "root", "password");
    mysql_select_db("cistdutrd");

    $query = mysql_query($query);
    $numrows = mysql_num_rows($query);

    if ($numrows > 0) {
        while ($row = mysql_fetch_assoc($query)) {
            $id = $row['id'];
            $TName = $row['Trial Name'];
            $TType = $row['Trial Type'];
            $TTeam = $row['Trial Team'];
            $Date = $row['Date'];
            $RHyperlink = $row['Report Hyperlink'];

            echo "<h2><a href='$link'>$TName<a/></h2>
            $TType<br /><br />";
        }

    }
    else

    echo "No results found for \"<b>$k</b>\"";

    //disconnect
    mysql_close ();

    ?>

</body>
</html>