Accessibility

Flash Article

 

Business Directory Sample: Flash MX 2004 Professional with PHP and MySQL


Table of Contents

Comments

Designing MySQL Tables

Creating the Database

The first thing that you will need is a database. Create a database called Blisting in MySQL.

If you are using web-based interface like phpMyAdmin, then you can just type the name of the database and click CREATE. If you are using command prompt, go to MySQL command prompt and type:

Mysql > CREATE DATABASE Blisting
         -> ;

Building the Tables

From the planning phase you know that there is some relation between the Category and the Business details. So you will have to create two MySQL tables: one for the categories and another one for the business details.

  1. Name the first table category. Use this SQL statement to create the table structure for the category table:

    CREATE TABLE category (
      cID tinyint(4) NOT NULL auto_increment,
      Category varchar(255) NOT NULL default '',
      PRIMARY KEY  (cID)
    ) TYPE=MyISAM;
    
    

    You just created the table called category where there are two fields, cID and Category.

    cID Category
  2. Name your second table directory. Use this SQL statement to create the directory table:

    CREATE TABLE directory (
      pID int(4) NOT NULL auto_increment,
      Category varchar(255) NOT NULL default '',
      Business varchar(255) NOT NULL default '',
      Address varchar(255) NOT NULL default '',
      Telephone varchar(255) NOT NULL default '',
      Website varchar(255) NOT NULL default '',
      Email varchar(255) NOT NULL default '',
      Details longtext NOT NULL,
      Picture varchar(255) NOT NULL default '',
      PRIMARY KEY  (pID)
    ) TYPE=MyISAM;
    
    

You just created another table called directory in which there are nine fields:

pID Category Business Address Telephone Website Email Details Picture

Note that there is a field called Category in this table. This field is required so that you can specify which category a business falls under. Also you will have to make sure the name of the category you specify here matches at least one of the categories in the category table.

Now you need to populate the tables with some dummy data.

Populating the Tables

Add some categories to the tables using the following steps:

  1. Use the following SQL statement to create categories:

    INSERT INTO category VALUES (1, 'Computers');
    INSERT INTO category VALUES (2, 'Automobiles');
    INSERT INTO category VALUES (3, 'Restaurant');
    INSERT INTO category VALUES (4, 'Clothing');
    
    
  2. Add some data to the directory table with the following SQL statement:

    INSERT INTO directory VALUES (1, 'Computers', 'Abson', 'ABSON (UK) Ltd, Campus 100, UK', '01952284303', 'http://www.abson.com', 'sales@abson.com', 'Manufacturers of quality computer products as well as scanners, digital cameras and LCD projectors. Our Site offers FAQ and technical support. \r\nContact us for your immediate needs or visit the site for more details.', 'abson.jpg');
    INSERT INTO directory VALUES (2, 'Automobiles', 'CFS Cars', '12, Sigma Towers', '9182712345', 'http://www.cfs.com', 'sales@cfs.com', 'We sell all kinds of automobile spare parts.', 'cfs.jpg');
    INSERT INTO directory VALUES (3, 'Computers', 'Tell', 'Tell technologies., Texas, USA', '8885608324', 'http://www.tell.com', 'sales@tell.com', 'Tell\'s commitment to customer value, to our team, to being direct, to operating responsibly and, ultimately, to winning continues to differentiate us from other companies. \r\nLook inside; we think customers, investors and others will find our story to be a unique one.', 'tell.jpg');
    INSERT INTO directory VALUES (6, 'Clothing', 'Illusion', '10, Park Palace II, Ahmedabad', '1234123', 'http://www.pixeltees.com/store/ssdesign', 's_saj@yahoo.com', 'We sell quality T-shirts at affordable price. We also do custom T-shirt design in single or multi colour.\r\nVisit our site for more details.', 'illusion.jpg');
    INSERT INTO directory VALUES (4, 'Restaurant', 'Indian Curry', '105 California Street, San Francisco, CA', '91827635', 'http://www.indiancurry.com', 'indiancurry@aol.com', 'Our Restaurant Specialties: Indian Food, Curry, Asian delicacies and Indian hospitality.\r\nVisit us for more details on the website.', 'indiancurry.jpg');
    INSERT INTO directory VALUES (5, 'Restaurant', 'Italiano', '2953 Baker Street, San Francisco', '65432567', 'http://italiano.com', 'sales@italiano.com', 'For a trip to Italy without the flight, Italiano provides you authentic Ilatian food.\r\n\r\nVisit us at our website. ', 'italiano.jpg');
    
    

Note that as you populate the directory table with data you are inserting JPG filenames into the Picture field. You will place your images inside a folder called images, however, the Picture value in the directory table does not contain the name of the folder, only the image filename. You will specify the folder name in the ActionScript later.

Why do this in this way? Say you decide to rename your folder containing the images. If you had mentioned the folder name in each Picture field and wanted to change the name or position of the folder, you would have to go and change all the fields. If you write the name of the image folder in ActionScript, you only have to make one change in the FLA file to change it for all images.