Print html table of mysql Database table

Hello guys !!
i would like to print all data of a database table to an HTML table
i’ve tried different methods
here’s some of code :
$sql = mysql_query(“SELECT * FROM students ORDER BY date_added DESC”);
$itemsCount = mysql_num_rows($sql); // count the output amount

if ($itemsCount > 0) {
echo “<table border=‘1’ id= results>
<tr>
<th>ID</th>
<th>student name </th>
<th>student age </th>
<th>date added</th>
</tr>”;
while($row = mysql_fetch_array($sql)){
$id = $row[“id”];
$student_name = $row[“student_name”];
$age = $row[“student_age”];
$date_added = strftime(“%b %d, %Y”, strtotime($row[“date_added”]));

         echo "&lt;table border='1' id= results&gt;";
         echo "&lt;td&gt;" .$id. "&lt;/td&gt;";
		 echo "&lt;td&gt;" .$student_name. "&lt;/td&gt;";
		 echo "&lt;td&gt;" .$age. "&lt;/td&gt;";
		 echo "&lt;td&gt;" .$date_added. "&lt;/td&gt;";
		 echo "&lt;/tr&gt;";
		 echo "&lt;/table&gt;";
         
}

the table i got is not very organized (columns)
any help plz ??? i’m 12 yrs old newbie !!

Hi,
Try replace with this code in your script:

if ($itemsCount > 0) {
echo "<table border='1' id= results>
<tr>
<th>ID</th>
<th>student name </th>
<th>student age </th>
<th>date added</th>
</tr>";
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$student_name = $row["student_name"];
$age = $row["student_age"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
  echo "<tr><td>" .$id. "</td>";
  echo "<td>" .$student_name. "</td>";
  echo "<td>" .$age. "</td>";
  echo "<td>" .$date_added. "</td></tr>";
}
echo "</table>";
}