html - convert php sql Result from Vertical to Horizontal -
the following code generate result(one record) in vertical table there way convert horizontal nice styling.. in addition if possible column in popup window using parameter in query, using jquery or css
<html> <head> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <? $table = $_get["table"]; $lon = $_get["lon"]; $lat = $_get["lat"]; $sql = "select st_geometrytype(geom) geometrytype, st_area(geom) area, * $table st_contains( geom, st_transform( st_setsrid( st_makepoint($lon, $lat), 4326), 2276))"; $db = pg_connect("dbname=db user=user password=pass"); $result = pg_query($db, $sql); while( $row = pg_fetch_assoc($result) ) { print "<table>"; foreach ( array_keys($row) $column_name ) { if ( $column_name <> "geom" ) { print "<tr>"; print "<th>" . $column_name . "</th>"; print "<td>" . $row[$column_name] . "</td>"; print "</tr>"; } } print "</table>"; } ?> </body> </html> so far using css style table.
th { text-align:right; padding-right:0.5em; } td { text-align:center; } many thanks..
your printing tr @ same time loop runs, make trs , vertical, make horizontal , loop this;
while( $row = pg_fetch_assoc($result) ) { print "<table>"; print "<tr>"; foreach ( array_keys($row) $column ) { if ( $column_name <> "geom" ) { print "<th>" . $column . "</th>"; } } print "</tr>"; print "<tr>"; <-- 1 here opening tag foreach ( array_keys($row) $column_name ) { if ( $column_name <> "geom" ) { print "<td>" . $row[$column_name] . "</td>"; } } print "</tr>"; <-- 1 here closing tag print "</table>"; }
Comments
Post a Comment