Database Reference
In-Depth Information
cgi . out {
page content here
}
To change the call to use CGI.pretty , write it like this:
cgi . out {
CGI . pretty ( page content here )
}
PHP
PHP doesn't provide much in the way of tag shortcuts, which is surprising given that
language's web orientation. On the other hand, because PHP is an embedded language,
you can simply write your HTML literally in your script without using print statements.
Here's a show_tables.php script that shifts back and forth between HTML mode and
PHP mode:
<? php
# show_tables.php: Display names of tables in cookbook database
require_once "Cookbook.php" ;
?>
<html>
<head><title>Tables in cookbook Database</title></head>
<body>
<p>Tables in cookbook database:</p>
<?php
# Connect to database, display table list, disconnect
$dbh = Cookbook :: connect ();
$stmt = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'cookbook' ORDER BY TABLE_NAME" ;
$sth = $dbh -> query ( $stmt );
while ( list ( $tbl_name ) = $sth -> fetch ( PDO :: FETCH_NUM ))
print ( $tbl_name . "<br />" );
$dbh = NULL ;
?>
</body>
</html>
To try the script, put it in the mcb directory of your web server's document tree and
request it from your browser as follows:
http://localhost/mcb/show_tables.php
The PHP script includes no code to produce the Content-Type: header because PHP
produces one automatically. (To override this behavior and produce your own headers,
consult the header() function section in the PHP manual.)
Search WWH ::




Custom Search