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?

Recommended Answers

All 3 Replies

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.

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>";
}
}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.