Submit all php pages you create, as well as the html pages that are rendered as a result of your actions.
This assignment uses information from multiple previous assignments, so please refer back to those assignments for login information, tutorials etc.
a) (5 point) Create a php page to display the result of the query
SELECT * FROM pg_tables
from your database schema.
Adapt the following example for this purpose:
http://wiki.cs.ndsu.nodak.edu/doku.php?id=classes:general:dbsamples:php_postgres
To avoid having your password in the file, please read the host, dbname, user, and password information from a file not in the public_html directory or its subdirectories.
Leave out the semicolon at the end of SQL statements. It is added automatically.
Notice that by default, the script will only return the 0th column of the output.
b) (5 points) Create a php page to read the name of a school. Add input validation as you see appropriate (you will not be graded on this).
c) (5 points) Upon submission: Print out the complete row for a school in the High_School table from assignment 2, based on the name that was entered.
Link Contents:
PHP example for Postgres database connection
<head>
</head>
<body>
<?php
// Make a connection to the database
// The values here MUST BE CHANGED to match the database and credentials you wish to use
$dbhost = pg_connect("host=hostname dbname=databasename user=username password=password");
// If the $dbhost variable is not defined, there was an error
if(!$dbhost)
{
die("Error: ".pg_last_error());
}
// Define the SQL query to run (replace these values as well)
$sql = "SELECT * FROM Schema.Tablename";
// Run the SQL query
$result = pg_query($dbhost, $sql);
// If the $result variable is not defined, there was an error in the query
if (!$result)
{
die("Error in query: ".pg_last_error());
}
// Iterate through each row of the result
while ($row = pg_fetch_array($result))
{
// Write HTML to the page, replace this with whatever you wish to do with the data
echo $row[0]."<br/>\n";
}
// Free the result from memory
pg_free_result($result);
// Close the database connection
pg_close($dbhost);
?>
</body>
</html>
Submit all php pages you create, as well as the html pages that are rendered as...