Home arrow PHP arrow Page 2 - Building a Quick and Easy Tag Board

Did Anyone Say MySQL? - PHP

Tag boards enable users to leave a short message on your site without having to go through the trouble of registering. From a development point of view, they are actually rather simple to develop. In this article we will create a quick and easy tag board for any web site. We will be taking advantage of the php and MySQL technologies.

TABLE OF CONTENTS:
  1. Building a Quick and Easy Tag Board
  2. Did Anyone Say MySQL?
  3. Our Tag Board Script
  4. What Makes Our Tag Board Tick?
  5. Our Tag Board Functions!
  6. Retrieval and Sorting of Tags
  7. Results
  8. doBoard() Function
  9. doInsert() Function
  10. Ensuring Data Submitted Does Not Fail
  11. Inserting into the Tag Board
By: Haiden Taylor
Rating: starstarstarstarstar / 120
November 03, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

As mentioned briefly on the previous page, our tag board will take advantage of a MySQL database to store the information (tags). The MySQL table I will be using for this is below:

CREATE TABLE `tagboard` (
`tagId` int(11) NOT NULL auto_increment,
`tag_name` varchar(55) NOT NULL default '',
`tag_url` varchar(255) NOT NULL default '',
`tag_entry` text NOT NULL,
`tag_date` int(11) NOT NULL default '0',
PRIMARY KEY (`tagId`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;


You will need to add this table to a MySQL database; you can do this through the MySQL console or through a program like phpMyAdmin.

Our above table will store all our data (tags) indexed by a tagId, which is assigned to each tag by MySQL; this is commonly referred to as an “auto_increment” index. The reason I have included this column is because it is my preferred method of indexing, and it enables us to easily identify the tags if we were to create some admin functions (e.g. delete-tags.php?tagId=123).

The next field in our table is “tag_name” which will store the users name, this is a varchar as most Internet users generally possess an Internet-only secret identity and generally write their “name” using a multitude of strange characters. Which is fine by us. The only restriction we have is the number of characters in that name, in our case 55; we administer this simply by setting maxlength=”55” in our HTML input tag (e.g. <input type="text" name="__name" size="20" maxlength="55" class="inputform">).

Following this we have “tag_url” which will store the URL of the user, if applicable, meaning this is not a required field. It is a varchar also and is limited to 255 characters by maxlength=”255” again.

Now we are storing the body of our tag in the “tag_entry” field. This field is of the text type; this is limited to 400 characters by our HTML input tags once again.

The next field is where we are storing our date, “tag_date” which is of the int type, and 11 characters long. Some of you may be wondering why I have chosen to use “int” instead if “date” or “date-time”. The reason I have done this is because we are using the php Unix Epoch style of timestamp (time()) rather than the a MySQL timestamp.



 
 
>>> More PHP Articles          >>> More By Haiden Taylor
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: