powek posallas
powek posallas

Reputation: 49

Quantity Drop Down Menu Box Not Working

I'm trying to create a quantity drop down box wherein the quantity ranges from 1 to $pro_qty. this code returns an error

Notice: Undefined variable: i in C:\xampp\htdocs\ecommerce\all_products.php on line 110

Notice: Undefined variable: i in C:\xampp\htdocs\ecommerce\all_products.php on line 110

Notice: Undefined variable: i in C:\xampp\htdocs\ecommerce\all_products.php on line 111

Notice: Undefined variable: i in C:\xampp\htdocs\ecommerce\all_products.php on line 111

Notice: Undefined variable: i in C:\xampp\htdocs\ecommerce\all_products.php on line 116

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

 }
 ?>

Upvotes: 0

Views: 128

Answers (1)

Ayyanar G
Ayyanar G

Reputation: 1545

change like this i your code,

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

Upvotes: 2

Related Questions