PHP
  Home arrow PHP arrow Page 9 - 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 - doInsert() Function
    ( Page 9 of 11 )

    The last of our three functions is the doInsert() function, which is given the task of inserting a tag into the database, returning the result of the insert, and then refreshing only the page in the Inline Frame to display all tags, which will hopefully include the tag the user just submitted.

    The code we used to achieve this is detailed below:

    function doInsert($__name, $__entry, $__url)
    {
    $conx = mysql_connect(HOST, USER, PASS) or die("Unable to connect to MySQL Server");
    mysql_select_db(DB) or die("Unable to select Database");

    $__name = addslashes($__name);
    $__url = addslashes($__url);
    $__entry = addslashes($__entry);

    if (empty($__name))
    {
    ?>
    <p style="font-family: verdana,arial,helvetica,sans-serif; font-size: 11px; background-color: #FFFFFF">Name Field Is Required</p>
    <meta http-equiv="refresh" content="5;url='board.php?do=Tags'">
    <?
    } elseif (empty($__entry))
    {
    ?>
    <p style="font-family: verdana,arial,helvetica,sans-serif; font-size: 11px; background-color: #FFFFFF">Entry Field Is Required</p>
    <meta http-equiv="refresh" content="5;url='board.php?do=Tags'">
    <?
    } else {
    $stSql = "INSERT INTO tagboard(tagId, tag_name, tag_url, tag_entry, tag_date) values('', '$__name', '$__url', '$__entry', ".time().")";
    $arrResult = @mysql_query($stSql);
    if (!$arrResult) { echo "Query Failed - Unable to Retrieve tags - ".mysql_error()." - Line: __LINE__"; exit(); }

    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'">
    <?
    }
    }
    }

    As you can see in this first part of our function, we connect to our MySQL database and then select the database we will be using, which as I mentioned earlier in the article uses our defined constants.



     
     
    >>> 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 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek