I seem to be having some trouble understanding mysql_fetch_array(). I've got a script and for some reason it seems to be skipping the first mysql result row but doing fine with every one after that.
Here's the code:
Code: Select all
$list_query = "SELECT first_name, last_name, students.student_id
FROM enrollment, students
WHERE enrollment.student_id = students.student_id
AND date >= '$date_start'
AND date < '$date_end'
ORDER BY date";
if (!($list_result = @ mysql_query($list_query, $connection)))
die (showerror());
$list_info = mysql_fetch_array($list_result);
if (empty($list_info))
{ echo '<tr><td class=body colspan=7 align=center>There were no registrations for this date.</td></tr>'; }
else
{
echo $list_info[0];
while ($list_info = mysql_fetch_array($list_result)) //why doesn't this return the first row?
{
$first_name = $list_info['first_name'];
...and so on assigning array elements to variables and then echoing them with formating.
I think this is a problem with mysql_fetch_array(), but I have no idea why.
Any thoughts?