In my program I have created a table that is scrollable, everything is working fine as far as the scroll bar showing up,the proper data being returned and so on.
What is strange and I can’t locate why, is that above the header of the table the word ‘echo’ is repeated 7 times, one for each record being returned. I’ve obviously got some flaw in my code, but I haven’t been able to locate it, any help is appreciated
<?php
echo "<div class='scrollableContainer'>";
echo "<div style=' height: 125px; width: 535px; font-size: 10px; overflow: auto;'>";
echo "<table class='referrals scrollable'>";
echo "<thead><tr>
<th class='date'>Date</th>
<th class='name'>Student Name</th>
<th class='email'>Email</th>
<th class='phone'>Phone</th>
<th class='status'>Status</th>
echo </tr></thead>";
$query2 = "select * from students where referred_by ='$referral_id_to_use'";
$result2 = mysql_query($query2);
$num_rows = mysql_num_rows($result2);
if($num_rows>0){
while ($row = mysql_fetch_array($result2))
{
extract($row);
$student_name=$first_name.' '.$last_name;
if($current_status=1)
{
$student_status="Active";
}else{
$student_status="Inactive";
}
echo "<tr>\n
<td class='date'><div>$date_joined</div></td>
<td class='name'><div>$student_name</div></td>
<td class='email'><div>$emailaddress</div></td>
<td class='phone'><div>$phone_number</div></td>
<td class='status'><div>$student_status</div></td>
echo </tr>";
}
}
echo "</table>";
echo "</div>";
echo "</div>";
?>
Again the extra line of echo’s appears above the table header.
Thank you
You have the word
echoas data between a</td>and</tr>.Since text isn’t allowed there, the browser is error recovering and moving it to somewhere it is allowed (before the table).
Delete the word ‘echo’ from the source.
This type of thing is easier to pick up by examining the generated HTML, and running the generated HTML through a validator, rather then just comparing the PHP to the rendering in the browser.