Skipping empty records in mysql with php
<p>I am trying to make a survey but when I have an empty record in my msql database he just shows an empty question is there a possibility to skip empty records?</p>

<pre><code>&lt;?php
session_start();

include "config.php";
connDB();


$some_questions = mysql_num_rows(mysql_query("SELECT id FROM question"));        

if($_POST['next'] &amp;&amp; $_SESSION['qnumber'] != '' &amp;&amp; $_POST['question'.$_SESSION['qnumber']] != '')
{
    if($_POST['question1']){
        $_SESSION['antwoordjes'] = $_POST['question1'];
    }else{
        $_SESSION['antwoordjes'] .= '|'.$_POST['question'.$_SESSION['qnumber']];
    }
    $_SESSION['qnumber']++;
    $questionnumber = $_SESSION['qnumber']++;
    $sql = "SELECT id, question FROM question WHERE id = '$questionnumber'";
    $result = mysql_query($sql);
    while ($count = mysql_fetch_array($result)){

        if($count['question'] == null)
        {
            $_SESSION['qnumber']++;
        }
    }

}

if($_POST['question'.$some_questions] != '' &amp;&amp; $_SESSION['qnumber'] &gt;= ($some_questions + 1))
{
    mysql_query("INSERT INTO answers (ip,answers,datum) VALUES ('".$_SERVER['REMOTE_ADDR']."','".$_SESSION['antwoordjes']."',NOW())");
    session_destroy();
    header("Location: outro.php");
}

if($_SESSION['qnumber'] == '' || $_SESSION['qnumber'] &gt;= ($some_questions + 1))
{
    $quest = 1;
    $_SESSION['qnumber'] = $quest;
}
else{
    $quest = $_SESSION['qnumber'];
}

$data = mysql_fetch_array(mysql_query("SELECT question,answers FROM question WHERE id='".$quest."'"));


$answers = explode('|',$data['answers']);

$quest = stripslashes($data['question']);

if(empty($_POST['atext']))
{

}else{

    $quest = $_POST['hsvraag'];
    $commentary = $_POST['atext'];
    toevoegenOverig($commentary, $quest);
}

?&gt;
&lt;script type="text/javascript"&gt; 
function disablefield(){ 
if (document.getElementById('yes_radio').checked == 1){ 
document.getElementById('textbox_A').disabled='disabled'; 
document.getElementById('textbox_A').value='';
}else{ 
document.getElementById('textbox_A').disabled=''; 
document.getElementById('textbox_A').value=''; } 
} 
&lt;/script&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;!-- &lt;script type="text/javascript" src="abc.js"&gt;&lt;/script&gt; --&gt; 
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt;
&lt;title&gt;Internet onderzoek&lt;/title&gt;
&lt;link href="style.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;table align="left"&gt;
&lt;/table&gt;
&lt;div class="centrum"&gt;
&lt;div class="header"&gt;Internetsurvey&lt;/div&gt;
&lt;div class="content" id="content"&gt;
&lt;div class="balk"&gt;Introductie | &lt;span style="color:#000033;"&gt;question&lt;/span&gt; | end&lt;/div&gt;
&lt;br/&gt;
&lt;form method="post" action="vragenv.php"&gt;
&lt;?php
$nummer = 1;
foreach($answers as $answer)
{
    echo '&lt;input id="yes_radio" type="radio" name="question'.$_SESSION['qnumber'].'" value="'.$nummer.'" id="answer'.$nummer.'" onChange="disablefield();"/&gt;&lt;label for="answer'.$nummer.'"&gt;'.$answer.'&lt;/label&gt;&lt;br /&gt;';
    echo '&lt;input type="hidden" name="hsvraag" value="'.$quest.'"/&gt;';
    $nummer++;
}
?&gt;
&lt;/br&gt;
&lt;br/&gt;&lt;input type="text" id="textbox_A" required name="atext"/&gt;&lt;br /&gt;
&lt;input type="submit" name="next" value="next" class="knop" /&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
