根据优先选择菜单中的优先选择,在选择菜单中显示数据库中的数据

时间:2019-06-03 09:11:42

标签: php mysql select

在我正在执行的页面上,我有四个选择下拉菜单,并且我希望第二,第三和第四选择菜单根据第一个选择下拉菜单中的选择显示数据库中的数据

我更新了下面的代码,以查看上面的链接后又出现了另一个错误

  

注意:试图在第88行的index.php中获取非对象的属性

我有以下代码

<?php
include("db-connection.php");

// Tyre search setup
$widthSql = "SELECT DISTINCT 'width' FROM 'tyres' WHERE 'width' > 0 ORDER BY 'width'";                    
$widthResult = $conn->query($widthSql);                    

$profileSql = "SELECT DISTINCT 'profile' FROM 'tyres' WHERE 'profile' > 0 ORDER BY 'profile'";
$profileResult = $conn->query($profileSql);

$wheel_sizeSql = "SELECT DISTINCT 'wheel_size' FROM 'tyres' WHERE 'wheel_size' > 0 ORDER BY 'wheel_size'";
$wheel_sizeResult = $conn->query($wheel_sizeSql);

$speed_ratingSql = "SELECT DISTINCT 'speed_rating' FROM 'tyres' WHERE 'speed_rating' > 0 ORDER BY 'speed_rating'";
$speed_ratingResult = $conn->query($speed_ratingSql);
?>

<div class="form-group col-lg-3 col-md-3 col-sm-12">
    <label>Width</label>
    <div class="field-inner">                                        
        <select class="custom-select-box" name="width">
        <?php
          if ($widthResult->num_rows > 0) {
           while($row = $widthResult->fetch_assoc()) { ?>
            <option value="<?php echo $row['width'] ?>"><?php echo $row['width'] ?></option>
        <?php }} ?>
        </select>
        <?php var_dump($widthResult); ?>
        </select>
    </div>
</div>

var_dump返回bool(false)

0 个答案:

没有答案