PHP/MySQL Database-Driven Websites
Shared by: HC111210143829
-
Stats
- views:
- 3
- posted:
- 12/10/2011
- language:
- English
- pages:
- 14
Document Sample


PHP/MySQL
Database-Driven Websites
How it Works
Tools
PHP and MySQL – open source; work on
both unix and PC platforms
Dreamweaver has built in tools for
working with PHP
PHP has built in tools for working with
MySQL
It is easier to do than it first appears
Database Design
Make a plan
Entity-Relationship Diagrams
Use Descriptive Names for Tables
Select appropriate data types
Build Database (MySQL-Front)
The Linklist Table
The Linklist Table: Dataset
Understanding Queries
Basic SELECT statement:
SELECT * FROM dbname
Basic INSERT statement:
INSERT INTO dbname (fieldname1,
fieldname2) VALUES (value1, value2)
Writing PHP pages
Connect to the Database
Perform Queries
Get data out from database and turn it
into variables
Write the variables into formatted output
Connecting to the Database
<?php
# Type="MYSQL"
# HTTP="true"
$hostname_linklist = "matrix.msu.edu";
$database_linklist = "comp";
$username_linklist = "comp";
$password_linklist = "password";
$ linklist = mysql_pconnect($hostname_ linklist,
$username_ linklist, $password_linklist) or
die(mysql_error());
$db = mysql_select_db($database_linklist,$ linklist)
or die ("Couldn't select database.");
?>
The Link List Example
A simple HTML annotated list
A database-driven version of the same list
Adding records to the database
Link List Example: Code
I’ve created plain text files of index.php and
other files in order to show you the code.
index.php
input.php
processForm.php
Link List Example: Includes
Use include files for html that will be used
on many pages, and for PHP functions
that will be re-used on many pages in the
site (such as connecting to the database)
htmlheader.inc
htmlfooter.inc
Simplify Site Design
Use CSS for layouts
Use include files for common html
elements
Use include files for database connection
info (security issue)
Related docs
Other docs by HC111210143829
Get documents about "