This repository has been archived on 2025-02-12. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
NeoStats/tools/sqlphp/rta_tables.php
2004-07-20 11:55:27 +00:00

59 lines
2.2 KiB
PHP
Executable file

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<!-- ------------------------------------------------------------ -->
<!-- Run Time Access -->
<!-- Copyright (C) 2004 Robert W Smith (bsmith@linuxtoys.org) -->
<!-- -->
<!-- This program is distributed under the terms of the GNU -->
<!-- LGPL. See the file COPYING file. -->
<!-- ------------------------------------------------------------ -->
<head>
<title>rta Table Editor</title>
</head>
<body>
<center><h3>rta Table Editor</h3></center>
<?php
// comment this line out if your PHP is compiled with postgresql client library
dl("pgsql.so");
// Suppress Postgres error messages
// error_reporting(error_reporting() & 0xFFFD);
// connect to the database Change the username, password here to match your configuraiton
$conn = pg_connect("host=localhost port=8888 user=blah password=blah");
if ($conn == "") {
printf("$s%s%s", "Unable to connect to application.<br>",
"Please verify that the application is running and ",
"listening on port 8888.<br>");
exit();
}
// Headings
print("<table border=3 cellpadding=4 align=center width=65%>\n");
print("<tr><th>Table Name</th><th>Description</th></tr>\n");
// execute query
$command = "SELECT name, help, nrows FROM rta_tables";
$result = pg_exec($conn, $command);
if ($result == "") {
print("<p><font color=\"red\" size=+1>SQL Command failed!</p>");
print("<p>Command: $command</p>\n");
exit();
}
for($row = 0; $row < pg_NumRows($result); $row++)
{
$tblname = pg_result($result, $row, 0);
$tblhelp = pg_result($result, $row, 1);
$tblrows = pg_result($result, $row, 2);
print("<tr>\n<td><a href=rta_view.php?table=$tblname&offset=0");
print("&nrows=$tblrows>$tblname</a></td>\n");
print("<td>$tblhelp</td></tr>\n");
}
print("</table>\n");
// free the result and close the connection
pg_freeresult($result);
pg_close($conn);
?>
</body>
</html>