par
yuuzhantar » 08 juin 2006, 17:41
Bonjour,
je suis en train de génèrer un script d'affichage des grilles de sudoku génèrées par un autre script
pour simplifier l'affichage, j'ai créé une fonction affcarre avec pour paramètre $num le numéro de la case
ensuite, dans la grille on appelle la fonction par exemple pour la case 2
affcarre(2);
les chiffres et le masque sont récupérés dans le debut du script
voici le script
$nombressudoku = $sudokuaff;
switch($newniveau)
{
case 0 : {$niveausudoku=3; break;}
case 1 : {$niveausudoku=4; break;}
case 2 : {$niveausudoku=5; break;}
case 3 : {$niveausudoku=6; break;}
case 4 : {$niveausudoku=7; break;}
default : {$niveausudoku=5; break;}
}
$masquesudoku = $masque[$niveausudoku];
switch($newniveau)
{
case 0 : {$niveauaff="tres facile"; break;}
case 1 : {$niveauaff="facile"; break;}
case 2 : {$niveauaff="normal"; break;}
case 3 : {$niveauaff="difficile"; break;}
case 4 : {$niveauaff="tres difficile"; break;}
default : {$niveauaff="normal"; break;}
}
function affcarre ($num)
{
if($masquesudoku['$num']==0)
{
echo "
<div align=\"center\">
<input name=\"num01\" type=\"text\" id=\"num$num\" size=\"3\" maxlength=\"1\">
</div>
";
}
else
{
echo "
<div align=\"center\" class=\"style1\">$nombressudoku[$num]</div>
";
}
}
?>
<html>
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
<body>
<p>
</p>
<p>Niveau : <? echo"$niveauaff";?></p>
<p>Chiffres du sudoku : <? echo"$nombressudoku";?></p>
<p>Masque de la grille : <? echo"$masquesudoku";?></p>
<form name="form1" method="post" action="">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30" height="30" align="center" valign="middle"><? affcarre(0); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(1); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(2); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(3); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(4); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(5); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(6); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(7); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(8); ?></td>
</tr>
<tr>
<td width="30" height="30" align="center" valign="middle"><? affcarre(9); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(10); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(11); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(12); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(13); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(14); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(15); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(16); ?></td>
<td width="30" height="30" align="center" valign="middle"><? affcarre(17); ?></td>
</tr>
mais il y a un problème avec le teste de la fonction
if($masquesudoku['$num']==0) on affiche un text field ( champ de formulaire ) et sinon on affiche le nombre du sudoku
et la page n'affiche que des champs de formulaire
je ne sais pas comment corriger l'erreur
pourriez vous m'aider svp ???
merci d'avance
note : je n'ai pas mis le script en entier, il était trop long, j'ai mis juste la partie qui a un problème.
yuuzhantar