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 "<table border='1' id= results>";
echo "<td>" .$id. "</td>";
echo "<td>" .$student_name. "</td>";
echo "<td>" .$age. "</td>";
echo "<td>" .$date_added. "</td>";
echo "</tr>";
echo "</table>";
}
the table i got is not very organized (columns)
any help plz !!!!!? i'm 12 yrs old newbie !!
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks