AJAX
  Home arrow AJAX arrow Page 2 - Using Prototip with AJAX
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  
AJAX

Using Prototip with AJAX
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2009-02-04


    Table of Contents:
  • Using Prototip with AJAX
  • Adding Some PHP
  • Extending the Tooltips with Additional Mark-up
  • Getting the Rules Right

  • 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


    Using Prototip with AJAX - Adding Some PHP
    ( Page 2 of 4 )

      

    We’ll also need some PHP to finish off this example; in a new page in your text editor add the following code:

     

    <?php

     

    //connection information

    $host = "localhost";

    $user = "root";

    $password = "your_password_here";

    $database = "prototip";

     

    //make connection

    $server = mysql_connect($host, $user, $password);

    $connection = mysql_select_db($database, $server);

     

    //get parameter

    $param = $_GET["q"];

     

    //query the database

    $query = mysql_query("SELECT * FROM contents WHERE tip LIKE '$param%'");

     

    //get the data

    $row = mysql_fetch_assoc($query);

    $contents = $row["content"];

     

    //return matching data

    echo $contents;

     

    mysql_close($server);

    ?>

     

    Save this in the main prototip directory as contents.php . This is a very basic PHP script for getting data out of a database that matches the incoming parameter which is available under the $_GET superglobal.  

    I’d like to point out that this is the minimum amount of code required for this type of operation; security has not been a consideration in this example, so this file should not be used in a mission-critical application that is publicly available.  

    To see this example, you’ll need to copy the prototip directory (containing the libraries, plugins and files that we’ve made so far) into a content-serving directory of your web server. You’ll also need a MySQL database called prototip containing a table called contents, with the name of each tooltip in a column called tip and the content for each tooltip in a column called content. To make it easier to load data into this table once created, I’ve included a text file in the source code download for this article which can be used to load the data.  

    Once this has been done, you should be able to run the new page and see something like this:

     



     
     
    >>> More AJAX Articles          >>> More By Dan Wellman
     

       

    AJAX ARTICLES

    - PHP AJAX Form Validation
    - Completing a User-Defined CSS Website with P...
    - Create a User-Defined CSS Website with PHP
    - Build A Better Twitter Chat Client Than Cham...
    - Using Division Equations to Make Web Forms S...
    - Using Integer Multiplication to Protect Web ...
    - Using Simple Checksums for Web Form Verifica...
    - Protecting Web Forms with AJAX
    - Using Prototip with AJAX
    - Using Prototip
    - Using the google.load() Method with Google`s...
    - How to Handle Ajax Errors
    - Uncompressing Source Files with Google`s AJA...
    - Using the jQuery Framework with Google`s Aja...
    - Using Google`s Ajax Libraries API




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