Home arrow MySQL arrow Page 2 - Online Photo Album Development using PHP and GD: Part 2

Code: Explained - MySQL

In this part Frank will explain how to code the photo album using PHP and MySQL. This is the second part of his series and focuses on building the user interface.

TABLE OF CONTENTS:
  1. Online Photo Album Development using PHP and GD: Part 2
  2. Code: Explained
  3. Configurating
  4. Connecting to the Database
  5. 1,2,3, Testing
By: Frank Manno
Rating: starstarstarstarstar / 34
April 22, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The HTML code is straight-forward; however, I'll explain the PHP code from above:

include("../include/config.php");
?>

We'll be including config.php in all of our files. The config.php file allows us to make use of global variables throughout our application. Our config.php file looks like this:

 
<p><!--p<-->// Include file for database connectivity 
<br />$db_server "localhost"
<
br />$db_user "admin"
<
br />$db_pass "admin"
<
br />$db_name "album"
<
br />// Number of images to display per row in gallery view 
<br />DEFINE("IMAGE_DISPLAY"3); 
<
br />/***** 
<br />* Connects to database system 
<br />*/ 
<br />function db_connect(){ 
<
br />global $db_server
<
br />global $db_user
<
br />global $db_pass
<
br />global $db_name
<
br />$dbcnx mysql_connect($db_server$db_user$db_pass) or die("Error connecting 
to database: " 
mysql_error()); 
<
br />$dbsel mysql_select_db($db_name$dbcnx) or die("Error reading from database 
table: " 
mysql_error()); 
<
br />} 
<
br />/***** 
<br />* Displays HTML output page. The message argument, if passed, 
<br />* will be displayed to the user. The title element, is passed, 
<br />* replaces the page title, and the cell Boolean places the page 
<br />* $msg between 
<td />
</td />
<br />*/ 
<br />function displayPage($msg ""$title=""$cell true){ 
<
br />

 
<br />
<br />
<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<br />
<tbody>
<tr>
<br />
<td>
<br />
<table cellspacing="0" cellpadding="3" width="60%" align="center" border="0">
<br />
<tbody>
<tr>
<br />
<td valign="top" width="40%">
<h1><!--p echo($title);--></h1></td>
<br /></tr>
<br /></tbody></table>
<br />
<table cellspacing="0" cellpadding="5" width="60%" align="center" border="0">
<br />
<tbody>
<tr>
<br /><!--p<-->// Display opening 
<td>tag 
<br />if ($cell) 
<br />echo(" </td>
<td>"); 
<br />echo($msg); 
<br />
<br />// Display closing </td>
<td>tag 
<br />if ($cell) 
<br />echo("</td>"); 
<br />

 
<br /></tr>
<br /></tbody></table>
<br /></td>
<br /></tr>
<br /></tbody></table>
<br />
<br /><!--p<-->} 
<br />

</p>

>

 
 
>>> More MySQL Articles          >>> More By Frank Manno
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- Xeround Releases Free Version of MySQL Cloud...
- Oracle Announces New MySQL Specialization
- Constant Contact Chooses SkySQL for MySQL Su...
- Revoke Statement in MySQL
- The Grant Statement in MySQL
- SuccessBricks Announces ClearDB Availability...
- Building a PHP ORM: Deploying a Blog
- TROSYS Launches Free MySQL Manager and Admin...
- Building an ORM in PHP: Domain Modeling
- Building an ORM in PHP
- MySQL Leads Open Source Market, Gets Cluster...
- Oracle Announces Milestone Release for MySQL
- How to Stop SQL Injection Attacks
- New Defragmentation Solution for SQL Server
- Comparison of MyISAM and InnoDB MySQL Databa...


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap

Dev Shed Tutorial Topics: