else statement not displaying data
<p>i have some code to check for duplicates in a db before submitting the data, but the statement i have does not work. if a duplicate is found a message is returned to the form. however, it is not working and i am sure it has to do with my else statements near the bottom of the file being incorrect. assume all connections are working. where is the error? many thanks </p>

<pre><code>&lt;?php
$array = split('[,]', $_POST['fileno']);

if (isset($_POST['submit'])) {
    foreach ($array as $fileno) {
        if ($fileno == '' &amp;&amp; $box == '')
            {
                echo '&lt;div style="background-color:#ffa; padding:2px; color:#ff0000;font-size:12px;font-weight:normal"&gt;' . 'You must incude a box and a file' . '&lt;/div&gt;';

            }
        elseif ($fileno == '')
            {

                echo '&lt;div style="background-color:#ffa; padding:2px; color:#ff0000;font-size:12px;font-weight:normal"&gt;' . 'You must enter a file reference' . '&lt;/div&gt;';
            }
        elseif ($box == '')
            {
                //echo error;
                echo '&lt;div style="background-color:#ffa; padding:2px; color:#ff0000;font-size:12px;font-weight:normal"&gt;' . 'You must enter a box' . '&lt;/div&gt;';
            }
        else
            {
                $sql = "SELECT custref FROM files WHERE custref = '$fileno' ";
                $result = runSQL($sql) or die(mysql_error());
                if (mysql_num_rows($result)&gt;0){
                    echo '&lt;div style="background-color:#ffa; padding:2px; color:#ff0000;font-size:12px;font-weight:normal"&gt;' . $fileno . '  is already in the database. No duplicates' . '&lt;/div&gt;';

                }
                $sql = "SELECT custref FROM boxes WHERE custref = '$box' ";
                $result = runSQL($sql) or die(mysql_error());
                if (mysql_num_rows($result)&gt;0){
                    echo '&lt;div style="background-color:#ffa; padding:2px; color:#ff0000;font-size:12px;font-weight:normal"&gt;' . $box . '  is already in the database. No duplicates' . '&lt;/div&gt;';
                }

                else
                    {
                        //insert into db;
                        echo '&lt;div style="background-color:#ffa; padding:2px; color:#33CC33;font-size:12px;font-weight:normal"&gt;' . $fileno . "Box: " . $box . $authorised . 'Successfull' . '&lt;/div&gt;';
                        $sql = "INSERT INTO `files` (customer, authorisation, boxstatus, boxref, custref, filestatus) VALUES ('$customer', '$authorised', '$boxstatus', '$box', '$fileno', $filestatus)";
                        $result = runSQL($sql) or die(mysql_error());
                        //echo 'This record is valid';
                        //header("Location: http://localhost/sample/admin/files/index.php");
                        //exit();
                    }
            }
    }
}
?&gt;
</code></pre>
