我正在尝试创建一个数量下拉框,其数量范围从1到$ pro_qty。此代码返回错误
注意:未定义的变量:我在第110行的C:\ xampp \ htdocs \ ecommerce \ all_products.php
注意:未定义的变量:我在第110行的C:\ xampp \ htdocs \ ecommerce \ all_products.php
注意:未定义的变量:我在第111行的C:\ xampp \ htdocs \ ecommerce \ all_products.php
注意:未定义的变量:我在第111行的C:\ xampp \ htdocs \ ecommerce \ all_products.php
注意:未定义的变量:我在第116行的C:\ xampp \ htdocs \ ecommerce \ all_products.php
<div id="products_box">
<?php
$get_pro = "select * from products ";
$run_pro = mysqli_query($con, $get_pro);
while($row_pro=mysqli_fetch_array($run_pro)){
$pro_id = $row_pro['product_id'];
$pro_cat = $row_pro['product_cat'];
$pro_brand = $row_pro['product_brand'];
$pro_title = $row_pro['product_title'];
$pro_price = $row_pro['product_price'];
$pro_image = $row_pro['product_image'];
$pro_qty = $row_pro['product_qty'];
echo "
<div id='single_product'>
<h4>$pro_title</h4>
<img src='admin_area/product_images/$pro_image' width='180' height='80' />
<p><b> Php $pro_price.00</b></p>
<a href='details.php?pro_id=$pro_id' style='float:left;'>Details</a>
<select>
for($i=1;$i<=$pro_qty;$i++) {
<option value='$i'>$i</option>
}
</select>
<a href='index.php'?pro_id=$pro_id'><button style='float:right'>Add to Cart</button></a>
</div>
";
}
?>
答案 0 :(得分:2)
像这样改变你的代码,
echo "
<div id='single_product'>
<h4>$pro_title</h4>
<img src='admin_area/product_images/$pro_image' width='180' height='80' />
<p><b> Php $pro_price.00</b></p>
<a href='details.php?pro_id=$pro_id' style='float:left;'>Details</a>
<select>";
for($i=1;$i<=$pro_qty;$i++) {
echo "<option value=$i>$i</option>";
}
echo "</select>
<a href='index.php'?pro_id=$pro_id'><button style='float:right'>Add to Cart</button></a>
</div>
";