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

Results - 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

First off we have checked whether the MySQL query has returned 1 or more rows. We do this because the query may be executed successfully, but there may be no tags stored in the database, so we need to let the user know that no tags have been submitted yet.

If one or more results were returned by the database, we will look through them, displaying them one at a time using a while loop. Since we used the mysql_fetch_assoc() function, we will be accessing the specific fields by using the following syntax, $array_name[‘field_name’] . Therefore in our script we would use the following to display the field name minus the slashes echo stripslashes($arrow[‘tag_entry’]);

Note: The reason we remove the slashes is because in the doInsert() function we add slashes to the posted data to improve database integrity.

You may also notice a function in around the code to display to the tag entry which is nl2br(). This function will change \n to <br /> which will improve overall formatting. More information is available at www.php.net/nl2br

In the instance where no rows were returned by the MySQL query, we would need to let the user know that there was nothing to display. We have achieved this with the “else” section of our if statement. If our MySQL query returned less than 1 row (e.g. no rows in the database), then we display a message to the user informing them of the situation.



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

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


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

Dev Shed Tutorial Topics: