没有结果被带回来

时间:2014-11-26 14:27:26

标签: php html sql forms no-response

我又一次绝望了。我正在尝试创建一个搜索页面,它会带回以下结果

$brandName = filter_has_var(INPUT_GET, 'brandName') ? $_GET['brandName']: null;
$shoeSize= filter_has_var(INPUT_GET, 'shoeSize') ? $_GET['shoeSize']: null;
$colour = filter_has_var(INPUT_GET, 'colour') ? $_GET['colour']: null;

但是当我提交网络表单时,它不会检索任何记录。 任何人都可以告诉我哪里出错了。

以下是我到目前为止所做的代码

<body>
     <table>
     <tr>
     <th>Brand</th>
     <th>Name</th>
     <th>Size</th>
     <th>Colour</th>
     <th>Gender</th>
     <th>Price</th>
     <th>Description</th>
     </tr>
<?php
include 'database_mysqli_conn.php';

$brandName = filter_has_var(INPUT_GET, 'brandName') ? $_GET['brandName']: null;
$shoeSize= filter_has_var(INPUT_GET, 'shoeSize') ? $_GET['shoeSize']: null;
$colour = filter_has_var(INPUT_GET, 'colour') ? $_GET['colour']: null;


$sql = "SELECT * FROM sh_brand b inner join sh_shoe s on b.brandID = s.brandID WHERE 1"; // use WHERE to implement the form to pull certain types of data

if (!empty($brandName)) {

    $sql= $sql." AND brandName = '$brandName'";

    }

if (!empty($shoeSize)) {

    $sql= $sql." AND shoeSize = '$shoeSize'";

}

if (!empty($colour)) {

    $sql= $sql." AND colour = '$colour'";

}

$stmt = mysqli_query($conn, $sql) or die(mysqli_error($conn));

while ($row = mysqli_fetch_assoc($stmt)) {
        $brandName = $row['brandName'];
    $shoeName = $row['shoeName'];
    $shoeSize = $row['shoeSize'];
    $colour = $row['colour'];
    $gender = $row['gender'];
        $price = $row['price'];
    $description = $row['description'];

    echo "<tr>
        <td>$brandName</td>
        <td>$shoeName</td>
        <td>$shoeSize</td>
        <td>$colour</td>
        <td>$gender</td>
                <td>$price</td>
                <td>$description</td>
    </tr>";

}


mysqli_free_result($stmt);
mysqli_close($conn);

?>
</table>
</body>
</html>

WEB FORM ------------

<body>
<form id ="SearchPage" action="SearchShoes.php" method="get">
<h1>Search Page</h1>

    Brand <input type="text" name="brandName" />

    Shoe Size <input type="text" name="shoeSize" />

    Colour <select name="colour">
                <option value = "greenn">Green</option>
                <option value = "white">White</option>
                <option value = "grey">Grey</option>
                <option value = "black">Black</option>
                <option value = "brown">Bronw</option>
                <option value = "white/red">White/Red</option>  
            </select>


        <input type ="submit" value-"Find shoes"/>

0 个答案:

没有答案