/********************************************************************************************* * Magnetitc AJAX - Version 1.7 * (C) 2005 - Garrison Locke * * This is just like the magnetic word kits you've seen before except this is on the * internet! It saves state when you release a piece and it updates itself every four * seconds. So if you're on it at the same time someone else is and they move something, * you'll see that piece move too. It uses AJAX and the dom-drag library by Aaron Boodman * of http://youngpup.net. * * http://www.broken-notebook.com. * * Copyright (c) 2005, Garrison Locke * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the http://www.broken-notebook.com nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * *********************************************************************************************/ //the database info file. customize the data in here for your database require_once("dbinfo.php"); //create a mysql connection $connection = mysql_connect($host, $username, $password) or die ('Cannot connect to the database because: ' . mysql_error()); $query = "Select * from magnetic_poetry"; //get all the words and positions from the database $result = mysql_db_query($dbname, $query); //the info from the database //arrays for the data from the database $id = array(); $word = array(); $top_value = array(); $left_value = array(); //enter the data from the database into the arrays for($x = 0; $row = mysql_fetch_array($result); $x++){ $id[$x] = $row["id"]; $word[$x] = $row["word"]; $top_value[$x] = $row["top_value"]; $left_value[$x] = $row["left_value"]; } $numWords = count($id); //the number of words there are in the database require_once("cpaint.inc.php"); //the AJAX library file. /****************************************************************** * function printTiles() * * @author - Garrison Locke * * The printTiles function goes through the data in the database * to create all the tiles. Each tile is in a div. That's basically * all this does. Pretty simple. * ******************************************************************/ function printTiles(){ global $id, $word, $top_value, $left_value, $numWords; $retHTML = ""; for($i=0; $i<$numWords; $i++){ $tileWidth = 7 * strlen($word[$i]); $tileHeight = 15; $retHTML .= '