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
escort Bursa Bursa escort Antalya eskort
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: