Diferència entre revisions de la pàgina «Solucio escacs php»
De wikiserver
(Es crea la pàgina amb «<source lang="php"> <!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> …».) |
|||
| (3 revisions intermèdies per 3 usuaris que no es mostren) | |||
| Línia 1: | Línia 1: | ||
<source lang="php"> | <source lang="php"> | ||
| − | <!DOCTYPE html> | + | |
| − | + | <!DOCTYPE html> | |
| − | + | <html> | |
| − | + | <head> | |
| − | + | <title>ESCACS</title> | |
| − | + | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| − | + | </head> | |
| − | + | <body> | |
| − | + | <h3> TABLERO DE AJEDREZ DINÁMICO </h3> | |
| − | + | <table width="270px" cellspacing="0px" cellpadding="0px" border="1"> | |
| − | + | <?php | |
| − | + | for($x=0; $x<9;$x++){ | |
| − | + | echo "<tr>"; | |
| − | + | for($i=0; $i<9;$i++){ | |
| − | + | /* Si es impar = 1 True por tanto blanco, primera casilla = 0 */ | |
| − | + | if(($x+$i)%2){ | |
| − | + | echo "<td height='30px' width='30px' bgcolor='black'></td>"; | |
| − | + | } | |
| − | + | else{ | |
| − | + | echo "<td height='30px' width='30px' bgcolor='white'></td>"; | |
| − | + | } | |
| − | + | } | |
| − | + | echo "</tr>"; | |
| − | + | } | |
| − | + | ||
| − | + | ?> | |
| − | + | </table> | |
| − | + | </body> | |
| − | + | </html> | |
| − | + | </source> | |
| − | + | ||
| − | + | <?php | |
| − | </ | + | |
| − | < | + | for ($i=0; $i <8 ; $i++) { |
| + | |||
| + | for ($j=0; $j <8 ; $j++) { | ||
| + | if($j%2==0) { | ||
| + | echo " * "; | ||
| + | }else{ | ||
| + | echo " * "; | ||
| + | } | ||
| + | } | ||
| + | echo "<br>"; | ||
| + | } | ||
| + | |||
| + | ?> | ||
Revisió de 17:20, 6 oct 2023
<!DOCTYPE html>
<html>
<head>
<title>ESCACS</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h3> TABLERO DE AJEDREZ DINÁMICO </h3>
<table width="270px" cellspacing="0px" cellpadding="0px" border="1">
<?php
for($x=0; $x<9;$x++){
echo "<tr>";
for($i=0; $i<9;$i++){
/* Si es impar = 1 True por tanto blanco, primera casilla = 0 */
if(($x+$i)%2){
echo "<td height='30px' width='30px' bgcolor='black'></td>";
}
else{
echo "<td height='30px' width='30px' bgcolor='white'></td>";
}
}
echo "</tr>";
}
?>
</table>
</body>
</html>
<?php
for ($i=0; $i <8 ; $i++) {
for ($j=0; $j <8 ; $j++) {
if($j%2==0) {
echo " * ";
}else{
echo " * ";
}
}
echo "
";
}
?>