Php loop ignoring first row of mysql data

Hi,

I new to php and am trying to echo information from a mysql database using php and a php whileloop but it ignores the first row. Could anybody explain to me what i a doing wrong?


$query=("SELECT question_id, question, distractor_1, distractor_2, distractor_3, distractor_4 FROM multiplechoice_db " );
$result = @mysqli_query ($dbcon, $query); // Run the query.
while($row = mysqli_fetch_array($result)):?>
<br>
<?php echo $row[‘question_id’];?>
<br>
<?php echo $row[‘question’];?>
<br>

                &lt;input type="radio" value="1" id=' distractor  &lt;?php echo $row['question_id'];?&gt;' name ='&lt;?php echo $row['question_id'];?&gt;'/&gt;&lt;?php echo $row['distractor_1'];?&gt;
                &lt;br&gt;
                &lt;input type="radio" value="2" id=' distractor  &lt;?php echo $row['question_id'];?&gt;'  name ='&lt;?php echo $row['question_id'];?&gt;'/&gt;&lt;?php echo $row['distractor_2'];?&gt;
                &lt;br&gt;
                &lt;input type="radio" value="3" id=' distractor  &lt;?php echo $row['question_id'];?&gt;'  name ='&lt;?php echo $row['question_id'];?&gt;'/&gt;&lt;?php echo $row['distractor_3'];?&gt;
                &lt;br&gt;
                &lt;input type="radio" value="4" id=' distractor  &lt;?php echo $row['question_id'];?&gt;'  name ='&lt;?php echo $row['question_id'];?&gt;'/&gt;&lt;?php echo $row['distractor_4'];?&gt;
                &lt;br&gt;
                &lt;input type="radio" checked='checked' style='display:none' value="5" id='distractor &lt;?php echo $row['question_id'];?&gt;' name='&lt;?php echo $row['question_id'];?&gt;'/&gt;
                &lt;br&gt;

<?php endwhile;?>
<p> <input id=“submit” type=“submit” name=“submit” value="Click To Submit Completed Quiz "></>

Hello friend,

if your new to php I’m going to suggest that you start by getting ride of the method your using to access the database and use pdo. Search the forums for the key word pdo and you’ll find lots. did a quick search and here you go: http://openegg.ca/how-to-connect-to-a-database-using-pdo.

once you get a good connection to the database use foreach loop to display your query… you cant go wrong with foreach its much much easier to handle dtabase queries.
hope this helps

I agree with robin01, but I still couldn’t see what was causing the first row to be missing. @gail_belfast89, can you show us the data in your table, and the output from your PHP code please (right-click and ‘view source’)?