topical media & game development

talk show tell print

student-wave-nm1-setPos.php / php



  <?php
  

get values


          include("student-wave-nn1-inc-connect.inc");
          // get the values from the ajax request...
          name = _POST["name"];
          x = _POST["x"];
          y = _POST["y"];
          // ... and update the coordinates (or create a new row if name does not exist)
          
          
  

update


          
          /* Use this for older versions of mysql (though its not worth it, since performance is bad)...
          
          name_exists = mysql_fetch_array(mysql_query("SELECT name FROM position WHERE name='name'"));
          if (name_exists)
                  mysql_query("UPDATE position SET x='x', y='y' WHERE name='name'");                
          else
                  mysql_query("INSERT INTO position (x,y,name) VALUES ('x','y','name')");
          
  	*/
          
  

query


          // use this for mysql-versions >= 4.1.0 instead, for better performance!
          mysql_query("INSERT INTO position (x,y,name) VALUES ('x','y','name') ON DUPLICATE KEY UPDATE x='x', y='y'");
          exit();
          
          /*
                  TODO remove inactive/old users from db.
  	*/
  ?>
  


(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.