Bind to named placeholders
Data access abstraction
PDO provides a data-access abstraction layer.
Regardless of which database you're using, you use the
same functions to issue queries and fetc
Write a series of functions that produce bits of
HTML, or bits of HTML with some embedded PHP
print a header or menu with a particular section highlighted
produce forms automatically
pass in a PHP array or database query res
HTML forms for data entry
The HTML form is the common mechanism for data entry.
On submitting a form
The GET request is sent to the same server that hosts the
HTML <form> and request the script
04.query_results.php, with the
Not using PDO
01.read_query.php: MySQL is hard coded.
/ database connection info
/ (1) Open the database connection
$connection = mysql_connect(DB_HOST, DB_USER, DB_PW);
/ (2) Run the quer
Querying web databases the 4-step process
Querying the database via Web browsers using PHP:
1. Connect to a database
database server location
user login details
2. Execute a query on the database through the connection
3. Fetch query results or query st
Smarty template files (.tpl)
A template file contains the presentational output with cfw_tags
that Smarty replaces with dynamic content.
PHP using template files
Assign content to Smarty, then display the templa
Separating logic from content
In Web Page Construction you learned to separate
content from presentation (HTML vs CSS)
To write better PHP, it is important that you separate
logic (PHP) from content (HTML)
For the small projects you have worked on so f
I Blackboard: Crash course on PHP" document
I PHP 5.2.5. on Yallara
Why Web Database Applications?
You are most likely interested in web database systems because:
I You want to develop server-side systems that dynamicall
I When we use the term the Web, we mean three major, distinct standards and the tools
based on these standards: the HyperText Markup Language (HTML), the Hypertext Transfer
Protocol (HTTP), and the TCP/IP networking protocol suite.
I HTML works w
A page to capture user input
GET - append to the query string.
The business logic script executes
the database query.
Query results are displayed in a
separate result page.
Two-component querying: example
An HTML form c
The twitter API provides many functions
that you can add to your web page,
posting tweets (requires authentication) for an
Access data item by numerical index
mysql_fetch_array() handles query result more elegantly:
An associative array for each row
Access data items by attribute names
This is a code frag