我正在购物车中担任产品推荐员,这类似于您去杂货店和冲动糖果时的冲动。
如下所示。当我单击下拉菜单时,它没有包含我要查找的数据。
我正在使用以下代码,我认为它将输入此数据:
<?php foreach($Fluoros['Fluoro'] as $Fluoro) {
echo $Fluoro['Fluoro'], '<br>';
}
?>
<select title="Add Fluoro To Your Cart" id="<?php echo $Fluoro['Description']; ?>" class="selectpicker white-drop crimp-part" data-width="auto">
<select title="Select Fluoro" id="<?php echo $Fluoros['Product']; ?>" class="selectpicker white-drop crimp-part" data-width="auto">
<?php foreach($Fluoros['Product'] as $Fluoro){
echo '<option ' . 'value = ' . $Fluoro['Fluoro'] . ' </option>';
}
?>
</select> ```
[enter image description here][1]
[1]: https://i.stack.imgur.com/AXygI.png
The data is being pulled in my "Cart " class. The Select statement below works and brings the correct results
```php
public function fluoroCart() {
$getFluoroProducts = $this->_db->query("SELECT i.Part_Number, i.Description
FROM Inventory i
INNER JOIN Product_Details pd on pd.Part_Number = i.Part_Number
WHERE pd.Category_ID = 15");
$fluoroProducts = $this->_db->results();
foreach($fluoroProducts as $Fluoro){
$Flouros [] = array( 'Fluoro'=>$Fluoro->Part_Number, 'Description'=>$Fluoro->Description);
}
}```
答案 0 :(得分:0)
在HTML中,选择选项值需要用引号引起来。另外,除了指示值之外,您还需要在开始和结束选项标签之间放置一些文本,以使其实际显示在菜单中。
<select>
<option value="some value">Some Value Text</option>
</select>
您需要像这样修改PHP
echo '<option value = "' . $Fluoro['Fluoro'] . '">'.$Fluoro['Fluoro'].' </option>';