hi to all. i'm looking for a free simple coded php tic tac toe game for my assignment. anyone ? thanks for the replies.
hi..here is several scripts for you.. just use these codes..copy past it with any text editor loike notepad.. save it with anything.php and then upload it to your server.. code number 1: <html> <head> <title>tic tac toe</title> <script> function create_tic_tac_toe_ai_array() { ai_array = new Array(9); for(var index = 0; index < ai_array.length; index++) { ai_array[index] = new Array(ai_array.length - index); for(var index2 = 0; index2 < ai_array[index].length; index2++) ai_array[index][index2] = index2; } return(ai_array); } function randomise_ai_array(tic_tac_toe_ai_array) { for(var index = 0; index < tic_tac_toe_ai_array.length; index++) for(var index2 = 0; index2 < tic_tac_toe_ai_array[index].length; index2++) { temp = tic_tac_toe_ai_array[index][index2]; rand = parseInt(Math.random() * tic_tac_toe_ai_array[index].length); tic_tac_toe_ai_array[index][index2] = tic_tac_toe_ai_array[index][rand]; tic_tac_toe_ai_array[index][rand] = temp; } } function create_tic_tac_toe() { this.Letter = ''; this.Play = -1; } function create_tic_tac_toe_array() { game_array = new Array(9); for(var index = 0; index < ai_array.length; index++) game_array[index] = new create_tic_tac_toe(); return(game_array); } function next_available_square(tic_tac_toe_array, square) { available_square = 0; for(index = 0; index <= square; index++) { while(tic_tac_toe_array[available_square].Letter != '') { available_square++; } if(index < square) available_square++; } if(available_square < 0 || available_square > 8) alert('oh my god available_square = ' + available_square); return(available_square); } function ai_play(tic_tac_toe_array, tic_tac_toe_ai_array, turn_number, trial_number) { for(var index = turn_number + trial_number; index < tic_tac_toe_ai_array.length; index++) { //Each increment in this loop is a possible move. for(var index2 = 0; index2 < tic_tac_toe_ai_array[index].length; index2++) { take_back_moves(tic_tac_toe_array, turn_number + trial_number); index3 = next_available_square(tic_tac_toe_array, tic_tac_toe_ai_array[index][index2]); trial_move(tic_tac_toe_array, index3, next_letter(tic_tac_toe_array)); if(win(tic_tac_toe_array, Player_Letter()) == true) { return(1); } if(turn_number + trial_number + 1 == tic_tac_toe_array.length) { return(0); } if(trial_number < 2) { return_value = ai_play(tic_tac_toe_array, tic_tac_toe_ai_array, turn_number, trial_number + 1); take_back_moves(tic_tac_toe_array, turn_number + trial_number + 1); if((return_value != 1 && next_letter(tic_tac_toe_array) == Player_Letter()) || (index2 == tic_tac_toe_ai_array[index].length - 1)) return(return_value); } } } } function Computer_Letter() { return(computer_letter); } function Player_Letter() { return(player_letter); } function play() { if(turn == Computer_Letter()) document.tic_tac_toe.message.value = 'My turn (' + Computer_Letter() + ')'; else document.tic_tac_toe.message.value = 'Your turn (' + Player_Letter() + ')'; if(win(tic_tac_toe, Computer_Letter()) == false && win(tic_tac_toe, Player_Letter()) == false && tied(tic_tac_toe) == false) { if(turn == Computer_Letter()) { ai_play(tic_tac_toe, ai_array, move_number(tic_tac_toe), 0); turn = Player_Letter(); } setTimeout('play();', 1000); } if(win(tic_tac_toe, Computer_Letter())) { document.tic_tac_toe.message.value = 'I win'; } if(win(tic_tac_toe, Player_Letter())) { document.tic_tac_toe.message.value = 'you win'; } if(tied(tic_tac_toe)) { document.tic_tac_toe.message.value = 'we tied'; } } function move_number(tic_tac_toe_array) { latest_move = 0; for(var index = 0; index < tic_tac_toe_array.length; index++) { if(tic_tac_toe_array[index].Play >= latest_move) latest_move = tic_tac_toe_array[index].Play + 1; } return(latest_move); } function next_letter(tic_tac_toe_array) { last_position = 0; for(var index = 0; index < tic_tac_toe_array.length; index++) { if(tic_tac_toe_array[index].Play > tic_tac_toe_array[last_position].Play) last_position = index; } if(tic_tac_toe_array[last_position].Letter == Computer_Letter()) return(Player_Letter()); else return(Computer_Letter()); } function user_move(square, Letter) { if(tic_tac_toe[square].Letter == '' && turn == Player_Letter()) { move(tic_tac_toe, square, Letter); turn = Computer_Letter(); document.tic_tac_toe.message.value = 'My turn (' + Computer_Letter() + ')'; } } function move(tic_tac_toe_array, square, Letter) { tic_tac_toe_array[square].Letter = Letter; tic_tac_toe_array[square].Play = move_number(tic_tac_toe_array); eval('document.tic_tac_toe.square' + square + '.value = \'' + Letter + '\''); } function trial_move(tic_tac_toe_array, square, Letter) { if(square < tic_tac_toe_array.length) { tic_tac_toe_array[square].Letter = Letter; tic_tac_toe_array[square].Play = move_number(tic_tac_toe_array); eval('document.tic_tac_toe.square' + square + '.value = \'' + Letter + '\''); } } function take_back_moves(tic_tac_toe_array, Play) { for(var index = 0; index < tic_tac_toe_array.length; index++) { if(tic_tac_toe_array[index].Play >= Play) { tic_tac_toe_array[index].Letter = ''; tic_tac_toe_array[index].Play = -1; eval('document.tic_tac_toe.square' + index + '.value = \'\''); } } } var ai_array; var tic_tac_toe; var turn; var computer_letter; var player_letter; function new_game() { if(Math.random() < 0.5) { computer_letter = 'x'; player_letter = 'o'; } else { computer_letter = 'o'; player_letter = 'x'; } if(Math.random() < 0.5) turn = Computer_Letter(); else turn = Player_Letter(); randomise_ai_array(ai_array); take_back_moves(tic_tac_toe, 0); } function init() { ai_array = create_tic_tac_toe_ai_array(); tic_tac_toe = create_tic_tac_toe_array(); new_game(); play(); } function win(tic_tac_toe_array, Letter) { //First row, first column, and diagonal. if(tic_tac_toe_array[0].Letter == Letter) { if(tic_tac_toe_array[1].Letter == Letter && tic_tac_toe_array[2].Letter == Letter) return(true); if(tic_tac_toe_array[3].Letter == Letter && tic_tac_toe_array[6].Letter == Letter) return(true); if(tic_tac_toe_array[4].Letter == Letter && tic_tac_toe_array[8].Letter == Letter) return(true); } //Second row, second column, and other diagonal. if(tic_tac_toe_array[4].Letter == Letter) { if(tic_tac_toe_array[3].Letter == Letter && tic_tac_toe_array[5].Letter == Letter) return(true); if(tic_tac_toe_array[1].Letter == Letter && tic_tac_toe_array[7].Letter == Letter) return(true); if(tic_tac_toe_array[2].Letter == Letter && tic_tac_toe_array[6].Letter == Letter) return(true); } //Third row and third column. if(tic_tac_toe_array[8].Letter == Letter) { if(tic_tac_toe_array[6].Letter == Letter && tic_tac_toe_array[7].Letter == Letter) return(true); if(tic_tac_toe_array[2].Letter == Letter && tic_tac_toe_array[5].Letter == Letter) return(true); } return(false); } function tied(tic_tac_toe_array) { if(win(tic_tac_toe_array, Player_Letter()) == false && win(tic_tac_toe_array, Computer_Letter()) == false) { for(var index = 0; index < tic_tac_toe_array.length; index++) if(tic_tac_toe_array[index].Letter == '') return(false); return(true); } return(false); } </script> </head> <body onload="init();"> <form name="tic_tac_toe"> <table> <tr> <td colspan="3" align="center"> <input type="text" size="9" name="message" style="border:none; text-align:center;" /></td> </tr> <tr> <td> <input type="text" size="1" name="square0" readonly onclick="user_move(0, Player_Letter());" /></td> <td align="center"> <input type="text" size="1" name="square1" readonly onclick="user_move(1, Player_Letter());" /></td> <td align="right"> <input type="text" size="1" name="square2" readonly onclick="user_move(2, Player_Letter());" /></td> </tr> <tr> <td> <input type="text" size="1" name="square3" readonly onclick="user_move(3, Player_Letter());" /></td> <td align="center"> <input type="text" size="1" name="square4" readonly onclick="user_move(4, Player_Letter());" /></td> <td align="right"> <input type="text" size="1" name="square5" readonly onclick="user_move(5, Player_Letter());" /></td> </tr> <tr> <td> <input type="text" size="1" name="square6" readonly onclick="user_move(6, Player_Letter());" /></td> <td align="center"> <input type="text" size="1" name="square7" readonly onclick="user_move(7, Player_Letter());" /></td> <td align="right"> <input type="text" size="1" name="square8" readonly onclick="user_move(8, Player_Letter());" /></td> </tr> <tr> <td colspan="3"><input type="button" value="new game" onclick="new_game(); play();" /></td> </tr> </table> </form> </body> </html> PHP:
------------------- code number 2: <?php ////////////////////////////////////////////////// // PHP Tic Tac Toe // // Created : 15/02/03 (dd/mm/yy) // // (c) 2003 Premshree Pillai // // http://www.qiksearch.com // // http://premshree.resource-locator.com // ////////////////////////////////////////////////// global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $bsize=3; $playerToken="X"; $myToken="0"; $gameOver=0; $winArr=array(); $rowArr=array(); $colArr=array(); $digArr=array(); // Arrays for testing for($x=0; $x<$bsize*$bsize; $x++) { $rowArr[$x]=0; $colArr[$x]=0; $digArr[$x]=0; } ?> <html> <head> <title>Tic Tac Toe in PHP</title> <style type="text/css"> .main{border:#9999CC solid 2px; width:350px} .btn{font-family:comic sans ms,verdana,arial,helvetica; font-size:20pt; font-weight:bold; background:#9999CC; width:50px; height:50px; border:#666699 solid 1px; cursor:hand; color:#EFEFFF} .btn_over{font-family:comic sans ms,verdana,arial,helvetica; font-size:20pt; font-weight:bold; background:#EFEFFF; width:50px; height:50px; border:#666699 solid 1px; cursor:hand; color:#9999CC} .btn_down{font-family:comic sans ms,verdana,arial,helvetica; font-size:20pt; font-weight:bold; background:#666699; width:50px; height:50px; border:#666699 solid 1px; cursor:hand; color:#EFEFFF} .footer{font-family:verdana,arial,helvetica; font-size:8pt; color:#FFFFFF} .link{font-family:verdana,arial,helvetica; font-size:8pt; color:#FFFFFF} .link:hover{font-family:verdana,arial,helvetica; font-size:8pt; color:#EFEFFF} </style> <script language="JavaScript"> var doneFlag=false; function toggleVal(who) { var check; eval('check=document.ttt.'+who+'_btn.value;'); if(check=="") { if(!doneFlag) { eval('document.ttt.'+who+'_btn.value="X";'); eval('document.ttt.'+who+'_btn.disabled="true";'); eval('document.ttt.'+who+'.value="X";'); document.ttt.submit(); doneFlag=true; document.getElementById('process').innerHTML="Processing........."; } } else { alert('Invalid Move!'); } } </script> </head> <body> <table width="100%" height="100%"><tr><td align="center"> <table width="346" align="center" bgcolor="#9999CC" cellspacing="0" cellpadding="0"><tr><td></td></tr></table> <table width="348" align="center" bgcolor="#9999CC" cellspacing="0" cellpadding="0"><tr><td></td></tr></table> <table align="center" cellspacing="0" cellpadding="0" class="main"><tr><td align="center"> <table width="100%" bgcolor="#9999CC" cellspacing="0" cellpadding="0"><tr><td align="center"><a href="tic-tac-toe.php"><img src="ttt_php.gif" border="0" alt="Tic Tac Toe (in PHP)"></a></td></tr></table> <table width="100%" bgcolor="#EFEFFF" cellspacing="0" cellpadding="0"><tr><td align="center"><a href="http://www.qiksearch.com"><img src="qiksearch_ttt_php.gif" border="0" alt="www.qiksearch.com"></a></td></tr></table> <? function genBox($size) { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $count=0; $retVal='<form name="ttt" method="post" action="tic-tac-toe.php">'; for($i=0; $i<$size; $i++) { for($j=0; $j<$size; $j++) { $count++; $retVal.='<input type="button" name="s'.$count.'_btn" value="" class="btn" onClick="toggleVal(\'s'.$count.'\')" onMouseover="this.className=\'btn_over\'" onMouseout="this.className=\'btn\'" onMousedown="this.className=\'btn_down\'"><input type="hidden" name="s'.$count.'" value="">'; } $retVal.='<br>'; } $retVal.='</form>'; echo $retVal; } function genBox2($size,$arr) { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $count=0; $retVal='<form name="ttt" method="post" action="tic-tac-toe.php">'; for($i=0; $i<$size; $i++) { for($j=0; $j<$size; $j++) { $count++; $retVal.='<input type="button" name="s'.$count.'_btn" value="'.$arr[$count-1].'" class="btn" onClick="toggleVal(\'s'.$count.'\')" onMouseover="this.className=\'btn_over\'" onMouseout="this.className=\'btn\'" onMousedown="this.className=\'btn_down\'"><input type="hidden" name="s'.$count.'" value="'.$arr[$count-1].'">'; } $retVal.='<br>'; } $retVal.='</form>'; echo $retVal; } function isEmpty($who) { if($who=="") return 1; else return 0; } function move($bsize,$arr) { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $count=0; $maxCount=0; $pos=0; $retVal=0; # Build Row Array for($i=0; $i<$bsize; $i++) { $maxCount=0; $fullCounter=0; for($j=0; $j<$bsize; $j++) { $count++; $who=$arr[$count-1]; if($who==$playerToken) { $maxCount++; $fullCounter++; } if($who==$myToken) $fullCounter++; } $rowArr[$i]=$maxCount; if($fullCounter==$bsize) $rowArr[$i]=-1; } # Building Column Array for($i=0; $i<$bsize; $i++) { $count=$i+1; $maxCount=0; $fullCounter=0; for($j=0; $j<$bsize; $j++) { $who=$arr[$count-1]; if($who==$playerToken) { $maxCount++; $fullCounter++; } if($who==$myToken) $fullCounter++; $count+=$bsize; } $colArr[$i]=$maxCount; if($fullCounter==$bsize) $colArr[$i]=-1; } # Building Diagonal Array for($i=0; $i<2; $i++) { if($i==0) $count=$i+1; else $count=$bsize; $maxCount=0; $fullCounter=0; for($j=0; $j<$bsize; $j++) { $who=$arr[$count-1]; if($who==$playerToken) { $maxCount++; $fullCounter++; } if($who==$myToken) $fullCounter++; if($i==0) $count+=$bsize+1; else $count+=$bsize-1; } $digArr[$i]=$maxCount; if($fullCounter==$bsize) $digArr[$i]=-1; } # Finding Max Values $maxRow=myMax(0,$bsize,"row",$rowArr); $maxCol=myMax(0,$bsize,"col",$colArr); $maxDig=myMax(0,$bsize,"dig",$digArr); $maxArrs[0]=myMax(1,$bsize,"row",$rowArr); $maxArrs[1]=myMax(1,$bsize,"col",$colArr); $maxArrs[2]=myMax(1,$bsize,"dig",$digArr); //$maxArrs=array(max(1,$bsize,"row",$rowArr),max(1,$bsize,"col",$colArr),max(1,$bsize,"dig",$digArr)); if(myMax(0,$bsize,"x",$maxArrs)==0) $pos=$bsize*($maxRow+1)-$bsize; if(myMax(0,$bsize,"x",$maxArrs)==1) $pos=$maxCol; if(myMax(0,$bsize,"x",$maxArrs)==2) if($maxDig==0) $pos=$maxDig; else $pos=$bsize-1; $retFlag=0; for($y=0; $y<$bsize; $y++) { if(!$retFlag) { if($arr[$pos]=="") { $retVal=$pos; $retFlag=1; } if(myMax(0,$bsize,"x",$maxArrs)==0) $pos++; if(myMax(0,$bsize,"x",$maxArrs)==1) $pos+=$bsize; if(myMax(0,$bsize,"x",$maxArrs)==2) if($maxDig==0) $pos+=$bsize+1; else $pos+=$bsize-1; } } return $retVal; } function myMax($what,$bsize,$type,$arr) { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $max=-1; $maxIndex=-1; if($type!="dig") { for($i=0; $i<$bsize; $i++) { if($arr[$i]>$max) { $max=$arr[$i]; $maxIndex=$i; } } } if($type=="dig") { for($i=0; $i<2; $i++) { if($arr[$i]>$max) { $max=$arr[$i]; $maxIndex=$i; } } } if($what==0) return $maxIndex; else return $max; } function playerWin() { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $who=$playerToken; if(($s1==$who && $s2==$s1 && $s3==$s1) || ($s4==$who && $s5==$s4 && $s6==$s4)||($s7==$who && $s8==$s7 && $s9==$s7) ||($s1==$who && $s4==$s1 && $s7==$s1) ||($s2==$who && $s5==$s2 && $s8==$s2) ||($s3==$who && $s6==$s3 && $s9==$s3) ||($s1==$who && $s5==$s1 && $s9==$s1) ||($s3==$who && $s5==$s3 && $s7==$s3)) return 1; else return 0; } function iWin() { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $who=$myToken; if(($s1==$who && $s2==$s1 && $s3==$s1) || ($s4==$who && $s5==$s4 && $s6==$s4)||($s7==$who && $s8==$s7 && $s9==$s7) ||($s1==$who && $s4==$s1 && $s7==$s1) ||($s2==$who && $s5==$s2 && $s8==$s2) ||($s3==$who && $s6==$s3 && $s9==$s3) ||($s1==$who && $s5==$s1 && $s9==$s1) ||($s3==$who && $s5==$s3 && $s7==$s3)) return 1; else return 0; } function whereWinComp() { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $who=$myToken; if(($s1==$who && $s2==$s1 && $s3==$s1)) $winArr=array('s1','s2','s3'); if(($s4==$who && $s5==$s4 && $s6==$s4)) $winArr=array('s4','s5','s6'); if(($s7==$who && $s8==$s7 && $s9==$s7)) $winArr=array('s7','s8','s9'); if(($s1==$who && $s4==$s1 && $s7==$s1)) $winArr=array('s1','s4','s7'); if(($s2==$who && $s5==$s2 && $s8==$s2)) $winArr=array('s2','s5','s8'); if(($s3==$who && $s6==$s3 && $s9==$s3)) $winArr=array('s3','s6','s9'); if(($s1==$who && $s5==$s1 && $s9==$s1)) $winArr=array('s1','s5','s9'); if(($s3==$who && $s5==$s3 && $s7==$s3)) $winArr=array('s3','s5','s7'); } function whereWinPlayer() { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $who=$playerToken; if(($s1==$who && $s2==$s1 && $s3==$s1)) $winArr=array('s1','s2','s3'); if(($s4==$who && $s5==$s4 && $s6==$s4)) $winArr=array('s4','s5','s6'); if(($s7==$who && $s8==$s7 && $s9==$s7)) $winArr=array('s7','s8','s9'); if(($s1==$who && $s4==$s1 && $s7==$s1)) $winArr=array('s1','s4','s7'); if(($s2==$who && $s5==$s2 && $s8==$s2)) $winArr=array('s2','s5','s8'); if(($s3==$who && $s6==$s3 && $s9==$s3)) $winArr=array('s3','s6','s9'); if(($s1==$who && $s5==$s1 && $s9==$s1)) $winArr=array('s1','s5','s9'); if(($s3==$who && $s5==$s3 && $s7==$s3)) $winArr=array('s3','s5','s7'); } function draw() { global $bsize,$playerToken,$myToken,$gameOver,$winArr,$rowArr,$colArr,$digArr,$vals,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9; $drawCounter=0; $dCounter=0; for($dCounter=0; $dCounter<sizeof($vals); $dCounter++) if($vals[$dCounter]!="") $drawCounter++; if($drawCounter==$bsize*$bsize) return 1; else return 0; } if($HTTP_POST_VARS) { $s1=$HTTP_POST_VARS["s1"]; $s2=$HTTP_POST_VARS["s2"]; $s3=$HTTP_POST_VARS["s3"]; $s4=$HTTP_POST_VARS["s4"]; $s5=$HTTP_POST_VARS["s5"]; $s6=$HTTP_POST_VARS["s6"]; $s7=$HTTP_POST_VARS["s7"]; $s8=$HTTP_POST_VARS["s8"]; $s9=$HTTP_POST_VARS["s9"]; $vals=array($s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9); if(draw() || playerWin()) $gameOver=1; # Computer's Move! $movIndex=move($bsize,$vals); if(!$gameOver) $vals[$movIndex]=$myToken; # Update S's if(!$gameOver) { if($movIndex==0) $s1=$myToken; if($movIndex==1) $s2=$myToken; if($movIndex==2) $s3=$myToken; if($movIndex==3) $s4=$myToken; if($movIndex==4) $s5=$myToken; if($movIndex==5) $s6=$myToken; if($movIndex==6) $s7=$myToken; if($movIndex==7) $s8=$myToken; if($movIndex==8) $s9=$myToken; } genBox2($bsize,$vals); if(playerWin()) { echo '<font face="verdana,arial,helvetica" color="#009900" size="4"><b>Wow! You Won!</b></font><br><br>'; echo '<input type="button" onClick="location.href=\'tic-tac-toe.php\'" value="Play Again!" style="background:#CCCCCC; font-weight:bold; cursor:hand"><br><br>'; whereWinPlayer(); echo '<script language="JavaScript">'; for($winCount=0; $winCount<sizeof($winArr); $winCount++) echo 'document.ttt.'.$winArr[$winCount].'_btn.style.color=\'#009900\';'; for($w=0; $w<$bsize*$bsize; $w++) if($vals[$w]=="") echo 'document.ttt.s'.($w+1).'_btn.disabled=true;'; echo '</script>'; $gameOver=1; } if (iWin() && !$gameOver) { echo '<font face="verdana,arial,helvetica" color="#FF0000" size="4"><b>Oops! You Lost!</b></font><br><br>'; echo '<input type="button" onClick="location.href=\'tic-tac-toe.php\'" value="Play Again!" style="background:#CCCCCC; font-weight:bold; cursor:hand"><br><br>'; whereWinComp(); echo '<script language="JavaScript">'; for($winCount=0; $winCount<sizeof($winArr); $winCount++) echo 'document.ttt.'.$winArr[$winCount].'_btn.style.color=\'#FF0000\';'; for($w=0; $w<$bsize*$bsize; $w++) if($vals[$w]=="") echo 'document.ttt.s'.($w+1).'_btn.disabled=true;'; echo '</script>'; $gameOver=1; } if(draw() && !playerWin() && !iWin()) { echo '<font face="verdana,arial,helvetica" color="#000000" size="4"><b>It\'s a Draw!</b></font><br><br>'; echo '<input type="button" onClick="location.href=\'tic-tac-toe.php\'" value="Play Again!" style="background:#CCCCCC; font-weight:bold; cursor:hand"><br><br>'; print '<script language="JavaScript">'; for($w=0; $w<$bsize*$bsize; $w++) if($vals[$w]=="") echo 'document.ttt.s'.($w+1).'_btn.disabled=true;'; echo '</script>'; } } else genBox($bsize); ?> <div style="font-family:verdana,arial,helvetica; font-weight:bold; font-size:10pt; color:#CC0000; background:#EFEFFF; width:100%; padding:3px" id="process"></div> <table width="100%" bgcolor="#9999CC"><tr><td><span class="footer">© 2004 <a href="http://www.qiksearch.com" class="link">Premshree Pillai</a> | <a href="http://www.guestbookdepot.com/cgi-bin/guestbook.cgi?book_id=374186" class="link">Sign my Guestbook</a>.</span></td></tr></table> </td></tr></table> <table width="348" align="center" bgcolor="#9999CC" cellspacing="0" cellpadding="0"><tr><td></td></tr></table> <table width="346" align="center" bgcolor="#9999CC" cellspacing="0" cellpadding="0"><tr><td></td></tr></table> </td></tr></table> </body> </html> PHP: ---------------------- any help be free to pm me..
Thanks for the codes. But some new features added to the assignment : Is it possible ? Also, I'm using code number 2.