remove empty values from database using php
<p>i'm making a php interface for procurement form. If there are empty fields when submitting the form nothing will be inserted into the database. I haven't used an array to insert empty value. I want to check for such empty fields and prevent from inserting empty values in the database.</p>

<pre><code>            &lt;table id="down"&gt;
            &lt;tr style="color: #fff;"&gt;
            &lt;th class="align"&gt;SN&lt;/th&gt;
            &lt;th class="align"&gt;Item Code&lt;/th&gt;
            &lt;th class="align"&gt;Item Name&lt;/th&gt;
            &lt;th class="align"&gt;Specification&lt;/th&gt;
            &lt;th class="align"&gt;Unit&lt;/th&gt;
            &lt;th class="align"&gt;Quantity&lt;/th&gt;
            &lt;th class="align"&gt;Unit Price&lt;/th&gt;
            &lt;th class="align"&gt;Total&lt;/th&gt;
            &lt;th class="align"&gt;Remarks&lt;/th&gt;
        &lt;/tr&gt;


         &lt;?php
            $a=1;
        ?&gt;
            &lt;?php
                do{
            ?&gt;        
            &lt;tr&gt;
            &lt;td&gt;&lt;input type="text" name="sn&lt;?php echo$a ?&gt;" size="3"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="item_code&lt;?php echo$a ?&gt;"size="7"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="item_name&lt;?php echo$a ?&gt;"size="30"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="specs&lt;?php echo$a ?&gt;"size="9"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="unit&lt;?php echo$a ?&gt;"size="9"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="qty&lt;?php echo$a ?&gt;"size="7"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="unit_price&lt;?php echo$a ?&gt;"size="5"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="total_price&lt;?php echo$a ?&gt;"size="7"/&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="remarks&lt;?php echo$a ?&gt;"size="30"/&gt;&lt;/td&gt;

        &lt;/tr&gt;

        &lt;?php
                $a=$a+1;
                }
                while ($a&lt;12);
            ?&gt;


        &lt;/table&gt;&lt;br/&gt;
        &lt;input type="reset" value="Reset" style="margin: auto; float: right;" /&gt;
        &lt;input type="submit" value="Send" style="margin: auto; float: right;" /&gt;&lt;br /&gt;
</code></pre>

<p>used the following code to insert multiple values.</p>

<pre><code>while($a&lt;8){
$sn=$_POST['sn'.$a];
$spc=$_POST['specs'.$a];
$iname=$_POST['item_name'.$a];
$unit=$_POST['unit'.$a];
$qty=$_POST['qty'.$a];
$uprice=$_POST['unit_price'.$a];
$tprice=$_POST['total_price'.$a];
$remark=$_POST['remarks'.$a];


$sql_po = "insert into procurement_products (sn, specs, item_name, unit, quantity, unit_price, total, remarks) values('$sn','$spc', '$iname', '$unit', '$qty', '$uprice', '$tprice', '$remark');";
mysql_query($sql_po) or die("Error in SQL: Cannot Insert".mysql_error());
$a=$a+1;
}
</code></pre>
