PHP搜索结果错误

PHP搜索结果错误,php,mysqli,Php,Mysqli,我已经写了下面的代码作为测试,但是结果没有出现在我创建的表格下,表格显示在顶部,所有结果显示在左侧,即使我没有在搜索中添加任何内容,所有结果都会显示。我看不出哪里出了错。我并不担心实际的HTML外观,因为它只是一个测试。谢谢你的帮助。错误是 index.php <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link rel= "stylesheet" href="style

我已经写了下面的代码作为测试,但是结果没有出现在我创建的表格下,表格显示在顶部,所有结果显示在左侧,即使我没有在搜索中添加任何内容,所有结果都会显示。我看不出哪里出了错。我并不担心实际的HTML外观,因为它只是一个测试。谢谢你的帮助。错误是

index.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <link rel= "stylesheet" href="style5.css"/>
</head>
<boby>
    <div class="third_bar"> 
        <div class="second_image"> 
        </div> 
        <div class="form"><form action= "search1.php" method="post"> 
            <input type="text" name="search" id="search_bar" placeholder="" value="Search for your whisky here" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/> 
            </form>  
        </div> 
</body>
    </div> 

</html> 
<?php

if (isset($_POST['search'])){

    include ('connect.php');


$search = $_POST['search'];

$query = "SELECT * FROM whisky_results";
$result = mysqli_query($conn, $query) or die ('error getting data');

echo "<table>";
echo "<tr> <th>Whisky Name</th> <th>Whisky Desription</th> <th>Highest Price Recorded</th> <th>Lowest Price Recorded</th> </tr>";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){

    echo "<tr><td>";
    echo $row['name'];
    echo "</td><td>";

    echo "<tr><td>";
    echo $row['description'];
    echo "</td><td>";

    echo "<tr><td>";
    echo $row['highest_price'];
    echo "</td><td>";

    echo "<tr><td>";
    echo $row['lowest_price'];
    echo "</td></tr>";

}

echo "</table>";

} else {
    echo "0 results";
}


?>

search1.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <link rel= "stylesheet" href="style5.css"/>
</head>
<boby>
    <div class="third_bar"> 
        <div class="second_image"> 
        </div> 
        <div class="form"><form action= "search1.php" method="post"> 
            <input type="text" name="search" id="search_bar" placeholder="" value="Search for your whisky here" max length="30" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="search_button" value="Go!"/> 
            </form>  
        </div> 
</body>
    </div> 

</html> 
<?php

if (isset($_POST['search'])){

    include ('connect.php');


$search = $_POST['search'];

$query = "SELECT * FROM whisky_results";
$result = mysqli_query($conn, $query) or die ('error getting data');

echo "<table>";
echo "<tr> <th>Whisky Name</th> <th>Whisky Desription</th> <th>Highest Price Recorded</th> <th>Lowest Price Recorded</th> </tr>";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){

    echo "<tr><td>";
    echo $row['name'];
    echo "</td><td>";

    echo "<tr><td>";
    echo $row['description'];
    echo "</td><td>";

    echo "<tr><td>";
    echo $row['highest_price'];
    echo "</td><td>";

    echo "<tr><td>";
    echo $row['lowest_price'];
    echo "</td></tr>";

}

echo "</table>";

} else {
    echo "0 results";
}


?>


首先,您的表单没有名为submittedOop的输入,谢谢。已如上所述进行更改,现在出现致命错误。听起来您可能没有安装mysqli。当你这样做的时候你会得到什么:echo扩展加载(“mysqli”)结果是1aha!数组有两个r。你只有一个。另外,在尝试使用$result之前,您应该检查$result是否为FALSE。首先,您的表单没有名为submittedOop的输入,谢谢。已如上所述进行更改,现在出现致命错误。听起来您可能没有安装mysqli。当你这样做的时候你会得到什么:echo扩展加载(“mysqli”)结果是1aha!数组有两个r。你只有一个。另外,在尝试使用$result之前,应该检查$result是否为FALSE。