Jump to content
Larry Ullman's Book Forums

stanos

Members
  • Posts

    4
  • Joined

  • Last visited

stanos's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hello again... things have gone well with my project till now..I made a function that calls the database every 10 seconds(using ajax) and if there is a move in the "moves" table in the database that move is displayed in the board,no matter on what browser we are...the thing is however,that if i make a move from chrome i want the next move to be done only from mozilla and particularly with the opposite colour..in other words i want somehow to eliminate the possibility of doing two sequential moves from the same browser...how can i achive this??
  2. somewhere in my code i have this block: request.onreadystatechange=function(){ if (request.readyState==4 && request.status==200){ document.getElementById("txtHint").innerHTML=request.responseText; some_func(); } } i observed that the function 'some_func' was called continuously messing things up... is there any way so that i can call the function 'some_func()' only once from that point?
  3. for example can i write the following function somewhere in my javascript file??? function update_table_with_the_lastmove(lastmove,game_id) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","get_lastmove.php?q="+lastmove&q2=+game_id,true); xmlhttp.send(); } and the php file could be this: <?php $q=$_GET["q"]; $q2=$_GET["q2"]; $con = mysql_connect('localhost', 'peter', 'abc123'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("chessbase", $con); $sql="UPDATE moves SET lastmove= '".$q."' WHERE game_id = '".$q."'"; $result = mysql_query($sql);
  4. Hello guys...i am writing a chess application using php mysql and javascript...my aim is to play chess through two different browsers under the same server though..for example when i make a move from chrome i want that move to be displayed in mozilla..how can i accomplish that?my first thought is using sessions that store the last move for each player...i have maid the whole interface and the database has two tables:'users' and 'games'... users conclude these columns:user_id,user_name,first_name,last_name,email,password,registration_date,rating,status games conclude these columns:game_id,date,user1_id,user2_id,user1_move,user2_move please help!!
×
×
  • Create New...