exclude array doesn't work in PHP
<p>below is my code through which I'm trying get certain values to a drop down box from a SQL database. I'm also trying to exclude some of the data before loading to the dropdown box.</p>

<p>In my code <code>$excld[]</code> works fine and the expected zero values are not shown when the dropdown is populated, but the values I expect to exclude via <code>$exclude=$rec['chkNum'];</code> doesn't work, or else the values I dont want to be in the dropdown still shows. Can someone tell me is there anything wrong in the approach?
thanks.</p>

<pre><code>$exclude = array();
$query = "SELECT * FROM invoentry WHERE dist_inv='$distUsr'";
$runx=mysqli_query($db,$query) or die ("SQL Error");
$norx=mysqli_num_rows($runx);

while ($rec = mysqli_fetch_array($runx))
{
    $exclude[] = $rec['chkNum']; $excld[] = '0';
}

$SQLx="SELECT * FROM newchk WHERE dist_chk='$distUsr'";
$runx=mysqli_query($db,$SQLx) or die ("SQL Error");
$norx=mysqli_num_rows($runx);

while ($rec = mysqli_fetch_array($runx))
    {
        if($rec['sbstart'] != '0' &amp; $rec['sbend'] != '0') {
        for($i=$rec['sbstart']; $i&lt;=$rec['sbend']; $i++)
        {
            if (!in_array($i, $exclude, $excld))
            {
                echo "&lt;option id='options' value='$i'&gt;$i&lt;br&gt;&lt;/option&gt;";
            }
        } }

         if($rec['gwstart'] != '0' &amp; $rec['gwend'] != '0') {
        for($i=$rec['gwstart']; $i&lt;=$rec['gwend']; $i++)
        {
            if (!in_array($i, $exclude, $excld))
            {
                echo "&lt;option id='options' value='$i'&gt;$i&lt;br&gt;&lt;/option&gt;";
            }
        } }
    }   
</code></pre>

<p><strong>EDIT :</strong></p>

<p>Database structure is as follows;
Database name :regional_data
Two tables in the same database invoentry and newchk</p>

<p><strong>invoentry:</strong></p>

<pre><code>usr_inv dist_inv chkNum InvoNum
---------------------------------
John     Guardian   300455   457gXT
</code></pre>

<p><strong>newchk:</strong></p>

<pre><code>usr_chk  dist_chk sbstart sbend totsb gwstart gwend totgw
----------------------------------------------------------
John     Guardian 300400  300550 151   300     310   10
</code></pre>
