Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > SERVER SIDE CODING > PHP TUTORIALS > PERSONALIZED WEB SITES IN A JIFFY


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

Personalized Web sites in a jiffy
By Steve Fox - 2004-02-02 Page:  1 2 3 4 5 6 7

Create your database

Your database is crucial to the performance of your Web site. It should be normalized (the process of assigning attributes to an entity, such as a customer or a product, which helps to avoid data redundancy), and designed with future growth in mind. Database design is beyond the scope of this article so I recommend that someone on your team be familiar with proper design.

I have included the table creation output from mysqldump in the file example_db.sql (included with the code zip file), so you can set up the database as in the example code. I have also included some sample data in the file example_db_data.sql, which you can use to seed the database. Create a database and a MySQL user to access the database. This user should be given select, insert, update, and delete privileges on this database. Be sure that you assign these privileges in the db table, rather than the user table, for security reasons. The db table can assign these privileges to a single database but the user table assigns privileges to all databases.

Import the tables and data using the command:

mysql -u username -p db_name < file.sql

where username is the name of any MySQL user who has access to this database, db_name is the name of your database, and file.sql is the file you are importing.

To run the example PHP code, you need to edit the database.php script and fill in these values. This script includes two function calls that connect to the MySQL server and select the database, respectively. By including these variables and function calls in a separate file, we can now access the database in any PHP script simply by including the database.php file.



View Personalized Web sites in a jiffy Discussion

Page:  1 2 3 4 5 6 7 Next Page: Let's customize

First published by IBM developerWorks


Copyright 2004-2017 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.