<?
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");             // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate");           // HTTP/1.1
header("Pragma: no-cache");
include("cgi-bin/area51/sk.inc");
include("cgi-bin/chess/chess.inc");
$db = connectAdmin_to_db_as_user();


$game_id=$game_id;
if($game_id=="") $game_id=1;

$resultIs = mysql_query("SELECT * FROM CHESS_GAME_DATABASE where id=$game_id",$db);




while ($row = mysql_fetch_object ($resultIs)) {

		$person_id=$row->person_id;
	 $event=$row->event;
		$site=$row->site;
		$date=$row->date;
		$round=$row->round;
		$white=$row->white;
		$black=$row->black;
		$result=$row->result;
		$nic=$row->nic;
		$eco=$row->eco;
		$opening=$row->opening;
		$comments=$row->comments;
		$notation=$row->notation;
		
	}
mysql_free_result ($resultIs);
	
?> 
<html>
<head>
 

<TITLE>Printable Game Format | PGN</TITLE>
	

	<link rel="stylesheet" type="text/css" href="/style.css">
</head>

<body bgcolor="ffffff">




<table border="0" cellpadding="5" cellspacing="0" width="650"><tr><td valign="top" width="300">

 <h3>Printable Game Format & PGN Format</h3> 
 <?
 if ($HTTP_REFERER!="") print("<a href=\"$HTTP_REFERER\">Back</a><p>");
 ?>
<i>Cut and Paste the following PGN format 
to your favorite PGN player</i>
<?
print("<hr>[Event \"$event\"]<br>
[Site \"$site\"]<br>");
print ("[Date \"$date\"]<br>");
print("[Round \"$round\"]<br>
[White \"$white\"]<br>
[Black \"$black\"]<br>
[Result \"$result\"]<br>
[NIC \"$nic\"]<br>
[Eco \"$eco\"]<br>
[Opening \"$opening\"]<p>
$notation<hr>");
   
   
   
/*





$pgn_game="
[Event \"\"]
[Site \"Buenos Aires Wch-m\"]
[Date \"1927\"]
[Round \"12\"]
[White \"Alekhine,Alexander\"]
[Black \"Capablanca,Jose R\"]
[Result \"1-0\"]
[NIC \"QO 11.3.6\"]

1.d4 Nf6 2.c4 e6 3.Nc3 d5 4.Bg5 Nbd7 5.e3 Be7 6.Nf3 O-O
7.Rc1 c6 8.Qc2 a6 9.a3 h6 10.Bh4 Re8 11.Rd1 b5 12.cb5 cb5
13.Bd3 Bb7 14.O-O Rc8 15.Qb1 Qa5 16.Ne2 Nb6 17.Ne5 Nc4
18.Bf6 Bf6 19.Bh7 Kf8 20.Nd7 Ke7 21.Nc5 Qb6 22.Nb7 Qb7
23.Bd3 Rc7 24.Qa2 Rec8 25.b3 Nd6 26.Qd2 Qb6 27.Rc1 Kd7
28.Rc7 Rc7 29.Bb1 Be7 30.Nf4 Kc8 31.Qe2 g6 32.Nd3 Ne4 33.b4
Rc3 34.Qb2 Qc7 35.Nc5 Bc5 36.dc5 Qe5 37.f4 Qg7 38.Be4 de4
39.Kf2 Qf6 40.g3 g5 41.Rc1
1-0
";
 
 


$firstHalf= substr ($pgn_game, 0, strrpos ($pgn_game, "]")+1 );
$tok = explode ( "\n", $firstHalf);
 for($xy=0; $xy < count($tok) ; $xy++){
	 print("$tok[$xy]<br>");
}
//echo "$firstHalf"; 
 */
 
 
 
 ?>
 
<!--

<img src="/chess/images/a_notation.gif"><br>
 -->
 <b>algebraic notation:</b><p>

<b>K</b> = King <b>Q</b> = Queen <b>R</b> = Rook <br>
<b>B</b> = Bishop <b>N</b> = Knight<p>

<table border="0" cellpadding="2" cellspacing="0"><tr><td>

<b>O-O</b>   </td><td>castling kingside</td></tr><tr><td>
<b>O-O-O</b>  </td><td>castling queenside</td></tr><tr><td>
<b>x</b>      </td><td>captures or takes</td></tr><tr><td>
<b>+</b>      </td><td>check (sometimes "ch.")</td></tr><tr><td>
<b>++</b>     </td><td>checkmate</td></tr><tr><td>
<b>=</b>      </td><td>a pawn promotion, as in f8=Q or d1=N.</td></tr><tr><td>
<b>e.p.</b>   </td><td>en passant.</td></tr><tr><td>
<b>#</b>      </td><td>checkmate </td></tr><tr><td>
<b>!!</b>     </td><td>an excellent move</td></tr><tr><td>
<b>!</b>      </td><td>a good move</td></tr><tr><td>
<b>!?</b>     </td><td>an interesting move</td></tr><tr><td>
<b>?!</b>     </td><td>a dubious move</td></tr><tr><td>
<b>??</b>     </td><td>a blunder</td></tr><tr><td>
<b>?</b>      </td><td>a bad move</td></tr><tr><td>
<b>1-0</b>    </td><td>white wins</td></tr><tr><td>
<b>0-1</b>    </td><td>black wins</td></tr><tr><td>
<b>1/2-1/2</b> </td><td>draw</td></tr>



</table>

<p>
 

</td><td  valign="top" width="350">
<a href="/"><img src="/chess/images/small_banner_logo.gif" border="0"></a><br>

<table border="1" cellpadding="3" cellspacing="0" width="350">




<?
print("<tr><td>#</td><td>White</td><td>Black</td><td>&nbsp;</td></tr>");

/*
$secondHalf = trim(substr ( strrchr ($pgn_game, "]") , 1));
$secondHalf = str_replace ("\n" , " ", $secondHalf);
*/
$notation=trim($notation);

$tok = explode ( " ", $notation);
 
 for($xy=0; $xy < count($tok) ; $xy++){
 	$break = explode ( ".", $tok[$xy]);
	if ($break[1]==""){
	 if ( $break[0]=="1-0" || $break[0]=="1/2-1/2" || $break[0]=="0-1"){
		$num=$num+1;
		 if ($num_left != 1 )print("<tr><td>$num</td><td>$break[0]</td><td>&nbsp;</td><td>&nbsp;</td></tr>");
	 	 else if ($num_left != 0 )print("<td>$break[0]</td><td>&nbsp;</td></tr>");
	 		
	 }  else print("<td>$break[0]</td><td>&nbsp;</td></tr>");
	 
	} else {
		$num = $break[0];
		$num_left = $break[0] % 2;
	 print("<tr><td>$break[0]</td><td>$break[1]</td>");
	}
}
print("</table>");
 
?>


 

</td></tr></table>


 


</td></tr></table>
</td></tr><tr><td align="left">
	



</table>



</BODY>

</html>