mysql - php code for shopping cart -


"hi, have problem here, want know how can put condition in code if want set button disabled if quantity below or equal 0. typed code below. hope can me."

<?php $results = $mysqli->query("select product_code, product_name, product_desc, product_img_name, qtyonhand, product_price allitems id <= 4"); if($results){ $products_item = '<ul class="products">'; while($obj = $results->fetch_object()) { $products_item .= <<<eot <li class="product"> <form method="post" action="../../cart_update.php"> <div class="product-content"><h3>{$obj->product_name}</h3> <div class="product-thumb"><img src="../../images/{$obj->product_img_name}" class="img"></div> <div class="product-info"> price {$currency}{$obj->product_price} <fieldset> <label> quantity left: {$obj-> qtyonhand}<br> <span>quantity</span> <input type="text" size="2" maxlength="2" name="product_qty" value="1" /> </label> </fieldset> <input type="hidden" name="product_code" value="{$obj->product_code}" /> <input type="hidden" name="type" value="add" /> <input type="hidden" name="return_url" value="{$current_url}" /> <div align="center"> <div align="center"> <button type="submit" class="add_to_cart" name="add_button" >add</button></div> </div></div> </form> </li> eot; } $products_item .= '</ul>'; echo $products_item; } ?> 

you can use this:

<input type="text" size="2" maxlength="2" {if($obj->qtyonhand<1, 'disabled="disabled"')} name="product_qty" value="1" /> 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -