<html> <head> <title>Vine Linux 2.6 Apache,PHP,PostgreSQL test(2)!</title> <script type="text/javascript"> function opensubwin(){ subwin=window.open("mytablecsv2.php","sub","width=600,height=200"); } </script> </head> <body> <?php $mysql="select * from mytable order by code"; echo("SQL : ".$mysql."<br><br>"); $mycon=pg_connect("dbname=template1 user=guest password=guest"); $myrs=pg_query($mycon,$mysql); echo("<table border=1><tr><th>Code</th><th>Name</th><th>Comment</th></tr>"); $myrows=pg_num_rows($myrs); for ($i=0; $i<$myrows; $i++) { $mydata=pg_fetch_row($myrs,$i); echo("<tr>"); for ($j=0; $j<count($mydata); $j++) { echo("<td>".htmlspecialchars($mydata[$j])."<br></td>"); } echo("</tr>"); } echo("</table>"); pg_free_result($myrs); //free result_set memory pg_close($mycon); ?> <form> <input type="button" value="Generate CSV file" onclick="opensubwin()"> </form> </body> </html>