PHP
  Home arrow PHP arrow Page 11 - Building a Quick and Easy Tag Board
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Building a Quick and Easy Tag Board
By: Haiden Taylor
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 120
    2004-11-03


    Table of Contents:
  • Building a Quick and Easy Tag Board
  • Did Anyone Say MySQL?
  • Our Tag Board Script
  • What Makes Our Tag Board Tick?
  • Our Tag Board Functions!
  • Retrieval and Sorting of Tags
  • Results
  • doBoard() Function
  • doInsert() Function
  • Ensuring Data Submitted Does Not Fail
  • Inserting into the Tag Board

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Building a Quick and Easy Tag Board - Inserting into the Tag Board
    ( Page 11 of 11 )

    The first and most significant is the SQL query we have used to insert the information into the database. That code is below:

    $stSql = "INSERT INTO tagboard(tagId, tag_name, tag_url, tag_entry, tag_date) values('', '$__name', '$__url', '$__entry', ".time().")";

    As you can see, we are Inserting Into our table “tagboard” into the following fields “(tagId, tag_name, tag_url, tag_entry, tag_date)”. We wish to place the following values, in order of how they appear, “values('', '$__name', '$__url', '$__entry', ".time().")";”. As you may have noticed we left the value which corresponds with tagId empty (‘’). We did this because as mentioned earlier the tagId field is auto increment, meaning if we leave the value empty, the next Id in line will be automatically assigned. We also used the php time() function for the tag_date field; this was explained in the “Did Anyone Say MySQL” section earlier in the article.

    Next we check to see if our MySQL query was executed successfully. Since we covered this section in the doTags() function, we will move along to our if statement. This code is detailed below:

    if (mysql_affected_rows() == 1)
    {
    ?>
    <meta http-equiv="refresh" content="3;url='board.php?do=Tags'">
    <?
    } else {
    echo "Unable to Add Entry to Database";
    ?>
    <meta http-equiv="refresh" content="5;url='board.php?do=Tags'">
    <?
    }

    In this snippet we check to see if any MySQL rows were affected, which if the insert was successful, we simply refresh the Inline Frame to display the doTags() function and the user will see their tag. If the query failed will inform the user, then refresh the Inline Frame back to the doTags() function. We then close our elseif statement and close our function. Displayed below:

    }
    }

    Conclusion

    As you can see it is possible to create a Tag Board for your site and have it running out of one php script. We have achieved all our requirements with three functions.

    If you followed this article correctly, you should have a tag board of your own ready to go on your site. You should also have the knowledge of how to Insert and retrieve data from a MySQL database.



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

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek