Beste,
Ik ben nieuw hier dus ik weet niet als ik het juiste forum gekozen heb om mijn probleem neer te zetten, in geval dat niet zo is verontschuldig ik mij dus.
Ik heb sinds kort een schaaksite runnen.
tijdens het spel zie je ook de geschiedenis van de zetten die reeds gemaakt zijn.
Daarvoor heb ik een stukje code gemaakt.
<code>
function writeHistoryPGN($format = "color", $single = 'none')
{
global $history, $numMoves, $MSG_LANG; $_SESSION;
if ($format == "color"){
echo '<table border="0" width="250" class="TABLE" align="center">';
echo "<tr><th class='THTOP'>Geschiedenis</th></tr>";
echo "<tr><td><div style='width:250;overflow:auto;height:147'><table border='1' width='230' align='center' cellspacing='0' cellpadding='3'>";
echo ("<tr><td bgcolor='#c0c0c0' width='30'><font color=black><b>Zet</font></td>");
echo ("<td bgcolor='white' colspan='2' align='center'><font color='black'><b>Wit</font></td>");
echo ("<td bgcolor='white' colspan='2' align='center'><font color='black'><b>Zwart</b></font></td></tr>\n");
}
for ($i = 0; $i <= $numMoves; $i+=2)
{
if ($format == "color")
$export = false;
else $export = true;
if ($format == "color")
echo ("<tr><td align='center' bgcolor='#BBBBBB'><font color='black'>".(($i/2)+1)."</font></td><td bgcolor='white' align='center'><font color='black'>");
$tmpReplaced = "";
if (!is_null($history[$i]['replaced']))
$tmpReplaced = $history[$i]['replaced'];
$tmpPromotedTo = "";
if (!is_null($history[$i]['promotedTo']))
$tmpPromotedTo = $history[$i]['promotedTo'];
$tmpCheck = ($history[$i]['isInCheck'] == 1);
if ($format == "plain" && $single != 'single')
{
if (ceil(($i+1)) > 1 && $single == 'chess')
{
echo "<br />";
}
echo ceil(($i+1)).". ";
}
$last_move=moveToPGNString($history[$numMoves]['curColor'], $history[$numMoves]['curPiece'], $history[$numMoves]['fromRow'], $history[$numMoves]['fromCol'], $history[$numMoves]['toRow'], $history[$numMoves]['toCol'], $tmpReplaced, $tmpPromotedTo, $tmpCheck);
$p = mysql_query("UPDATE games SET last_move='".$last_move."' WHERE gameID=".$_SESSION['gameID']."");
echo moveToPGNString($history[$i]['curColor'], $history[$i]['curPiece'], $history[$i]['fromRow'], $history[$i]['fromCol'], $history[$i]['toRow'], $history[$i]['toCol'], $tmpReplaced, $tmpPromotedTo, $tmpCheck, $export, $single)." ";
if ($format == "color")
{
echo "</td><td align='center' bgcolor='#C6D9EC' height=18>";
if ($tmpReplaced!="")
echo "<img src='./images/pieces/".$_SESSION['pref_theme']."/black_".$tmpReplaced.".gif' height='15' align='left'> ";
echo ("</font></td><td bgcolor=white align='center'><font color='black'>");
}
if ($i == $numMoves){
if ($format == "color")
echo (" ");
}
else
{
$tmpReplaced = "";
if (!is_null($history[$i+1]['replaced']))
$tmpReplaced = $history[$i+1]['replaced'];
$tmpPromotedTo = "";
if (!is_null($history[$i+1]['promotedTo']))
$tmpPromotedTo = $history[$i+1]['promotedTo'];
$tmpCheck = ($history[$i+1]['isInCheck'] == 1);
if ($format == "plain")
echo ceil(($i+1)/2).". ";
echo moveToPGNString($history[$i+1]['curColor'], $history[$i+1]['curPiece'], $history[$i+1]['fromRow'], $history[$i+1]['fromCol'], $history[$i+1]['toRow'], $history[$i+1]['toCol'], $tmpReplaced, $tmpPromotedTo, $tmpCheck,$export,$single)." ";
if ($format == "color")
{
echo "</td><td align='center' bgcolor='#C6D9EC' height=18>";
if ($tmpReplaced!="")
echo "<img src='./images/pieces/".$_SESSION['pref_theme']."/white_".$tmpReplaced.".gif' height='15' align='left'> ";
}
}
if ($format == "color")
echo ("</font></td></tr>\n");
//else{
//if (floor(($i+1)/8) == ($i)/8 && $i != 0)
// echo "\n";
// }
}
if ($format == "color")
echo ("</table></div></table>\n");
}
</code>
Deze dus.
Dit laat inderdaad de zetten zien van zet 1 tot ....
Nu staat zet 1 bovenaan, het is de bedoeling dat zet 1 onderaan staat en de laatste zet bovenaan.
Maar ik krijg het dus niet voor elkaar.
Kan iemand mij helpen aub...?
Mario
1.125 views