php query database print to html table with headers -


i have never programmed in php before , haven't touched html in 10 years. use help. querying postgresql database using php. trying display query results in table format headers this:

first_name   last_name   employee_id tom          jones       111 bob          barker      112 bill         davis       113 

sample code trying work correctly:

echo("<table border=2"); while ($line = pg_fetch_array($result, null, pgsql_assoc)) {     foreach ($line $col_value => $row_value) {         echo("<tr><td>$col_value</td><td>$row_value</td></tr>\n");     } } echo("</table>"); 

my formatting being displayed this:

first_name tom last_name jones employee_id 111 first_name bob last_name barker employee_id 112 first_name bill last_name davis employee_id 113 

as can see storing query in associative array.

thanks help.

echo("<table border=2><tr><td>first_name</td><td>last_name</td><td>employee_id</td></tr>"); while ($line = pg_fetch_array($result, null, pgsql_assoc)) {     echo("<tr>");     foreach ($line $col_value => $row_value) {         echo("<td>$row_value</td>");     }     echo("</tr>\n"); } echo("</table>"); 

or:

echo("<table border=2><tr><td>first_name</td><td>last_name</td><td>employee_id</td></tr>"); while ($line = pg_fetch_array($result, null, pgsql_assoc)) {     echo("<tr><td>".$line[0]."</td><td>".$line[1]."</td><td>".$line[2]."</td></tr>\n"); } echo("</table>"); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -