topical media & game development
sample-jquery-state.php / php
<?php
open database
to create
// uncomment the block below and
// call this script if you lost the database file
// (visit http://locationofthis/update.php)
/*
db->query("BEGIN;
CREATE TABLE boxes (
text CHAR(140),
x INTEGER(5),
y INTEGER(5)
);
COMMIT;");
*/
addbox
function addBox(db) {
string));
if (strlen(y = rand(20,600);
db->query("BEGIN;
INSERT INTO boxes (text,x,y)
VALUES ('".x."','".
delete box
function deleteBox(id, id == "all")
db->query("DELETE FROM boxes WHERE rowid = '
update
function update(db) {
result = query, SQLITE_ASSOC);
echo json_encode(
move
function move(x, id, db->query("UPDATE boxes set x='y' WHERE rowid='
select action
switch (_POST["action"]) {
case "new":
addBox(db);
update(_POST["boxid"], _POST["x"], _POST["id"], db);
break;
case "update":
update(
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.