PHP搜索结果错误

时间:2017-01-10 18:41:19

标签: php mysqli

我已经将下面的代码编写为测试,但结果没有在我创建的表格下面进行,表格显示在顶部,所有结果都显示在左侧,即使我没有添加任何结果搜索所有结果显示。?,无法看到我出错的地方。我并不担心实际的HTML Look,因为它只是一个测试。感谢帮助。错误是

的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> 

search1.php

<?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";
}


?>

0 个答案:

没有答案
相关问题