Display data from SQL database into html table


Objective: Echo out database table to html doc.
As a fine rule, I do not mix any script with html. CSS, Javascript, PHP files stand separate on separate folders.
In the past I used .php for my html files, so they contained php. With this practise, it was easy to echo out database data directly on html tags. But i have stopped the practise.
Take this case I am presently battling with:

    <section id="message">
        <h1>Welcome Page </h1>
        <article> </article>


// some js here
$.post('./php/database_tables/download_messages.php', {id: data}, function(data) {
	$('#messages article').eq(0).html(data);


// some php here
$output = '<table><caption>Public Messages</caption><thead><tr><th>id</th><th>fullname</th><th>username</th><th>email address</th><th>message</th><th>response</th><th>date created</th><th>date completed</th></tr></thead><tbody>';

while($row) {
	$output .= '<tr><td>' .$row["id"]. '</td><td>' .$row["fullname"]. '</td><td>' .$row["username"]. '</td><td>' .$row["email_address"]. '</td><td>' .$row["message"]. '</td><td>' .$row["response"]. '</td><td>' .$row["date_created"]. '</td><td>' .$row["date_completed"]. '</td></tr>';

$output .= '</tbody></table>';
echo $output;
// some php here

I have run these scripts many times. Earlier I was getting error regarding oversized data. So I used ini_set('memory_limit', '4095M'); Now I am getting error Maximum execution time of 30 seconds exceeded

How do I solve this problem.I don’t believe the only way out is to lump html and php together in one doc with extension .php ( thus echo out easily databes data to html


You return a JSON object, parse it, and the append it into the table. If this isn’t a school assignment, an easy way to handle this is through something like datatables.net