jeudi 2 juillet 2015

Add or Remove Out Of Stock Data From MySql Output in Php

I need to apply WHERE status!='disable' in my php code at $result after I click on the checkbox and then on uncheck of the checkbox it should be removed again and both enable and disable datas from MySql should be shown in the php, is that possible without using AJAX codes, if it is then how can I do that. Can anyone find where am I going wrong

Checkbox, code given below:

<h4 id="CATEGORIESfilters">Availability</h4>
<table border="0" cellspacing="0" id="Availabilitytable">
    <tr>
        <td>
            <input type="checkbox" name="Availability" id="Availabilitycheckboxexcludeoutofstock" >
        </td>
        <td>
            <label for="Availabilitycheckboxexcludeoutofstock">Exclude Out Of Stock</label>
        <td>
    </tr>
</table>

Php Code is given below:

<?php
    include "db_connection.php";
    if(isset($_REQUEST['Availability']))
    {
        $availability="WHERE status!='disable'";
    }
    else
    {
        $availability="";
    }
    $result = mysql_query("SELECT * FROM burger $availability ORDER BY product_no_id DESC");
    while($data=mysql_fetch_array($result)):
    if($data['status']=="enable")
    {
?>
<div class="productwrap">
    <div id="Instockwrap">
            In Stock
    </div>
</div>
<?php
    }
    else
    {
?>
<div class="productwrap">
    <div id="Outofstockwrap">
            Out Of Stock
    </div>
</div>
<?php
    }
    endwhile;
?>




Aucun commentaire:

Enregistrer un commentaire