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