0

I have the following code..

echo "<table align='center' border='1': bordercolor='silver'>";
echo "<tr>";
echo "<td align='center' width='200'>"  .  "<h4> "."Course" . "    " . "</td>";
//echo "<td>"  .  "            " ."</td>";
echo "<td align='center' width='200'>"  .  "<h4> "."Classes Attended" . "    " . "</td>";
//echo "<td>"  .  "            " ."</td>";
echo "<td align='center' width='200'>"  .  "<h4> "."Classes Missed"   . "    " . "</td>"; 
echo "</tr>";
//echo "</table>";
echo "<tr>";
while($row = mysql_fetch_array($resultAttendancePercent)){
echo "<br />";
//echo "<td align='center' width='200'>".$row['st_classes_attempt'] . "</td>";
//echo "<table border='1': border-color: silver;'>";
echo "<tr>";
echo "<td align='center' width='200'>".$row['course_name'] . "</td>";
echo "<td align='center' width='200'>".$row['st_classes_attempt'] . "</td>";
echo "<td align='center' width='200'>".$row['st_classes_missed'] . "</td>";
echo "</br>";
echo "</tr>";
echo "</table>";
}
echo "</tr>";
}

I am retrieving three columns from the database, but only one row is fetched in the table the other one is bieng displayed out of it. Can some one find out my mistake in my table code?

2
Contributors
3
Replies
13
Views
2 Years
Discussion Span
Last Post by JorgeM
0

The implementation of your table doesnt seem to be correct. For example, i see you are trying to start a new row on line 10, but again on line 15, then you close the table on line 21, but are trying to close a row on 23.

OPen this page in a browser and view source so you can actually look at hte HTML without the PHP code.

0

I have changed the code to the following, but the problem remains the same.

echo "<table align='center' border='1': bordercolor='silver'>";
echo "<tr>";
echo "<td align='center' width='200'>"  .  "<h4> "."Course" . "    " . "</td>";
echo "<td align='center' width='200'>"  .  "<h4> "."Classes Attended" . "    " . "</td>";
echo "<td align='center' width='200'>"  .  "<h4> "."Classes Missed"   . "    " . "</td>"; 
echo "</tr>";

while($row = mysql_fetch_array($resultAttendancePercent)){
echo "<br />";

echo "<tr>";
echo "<td align='center' width='200'>".$row['course_name'] . "</td>";
echo "<td align='center' width='200'>".$row['st_classes_attempt'] . "</td>";
echo "<td align='center' width='200'>".$row['st_classes_missed'] . "</td>";
echo "</br>";
echo "</tr>";
echo "</table>";
}
}

Edited by engrjd91

0

You want to have your closing table tag outside of the loop. The only thing that should be in the loop is the creation of rows and cells.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.