好吧,所以我有这个部分工作的游戏,我知道解决方案应该是简单的游戏玩法,但对于noob而言,没有什么是简单的,所以在这里,我请求帮助,作为noob,我做错了什么,我认为这是我设置复选框的方式,但我需要其他的眼睛,谢谢。php战列舰游戏不工作
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" />
<table border="1" align="center" />
<?php
$fire = $_REQUEST["fire"];
$variable = $_REQUEST["variable"];
$step = $_REQUEST["step"];
$i = $_REQUEST["i"];
$j = $_REQUEST["j"];
if(isset($_POST['$i$j']))
{
echo 'checked';
}
//first there will be script that randomly generate 5 ships for both users
$step = $_POST['step'];
//4 steps of the game
if ($step > 3)
{
$step = 1;
}
else
{
$step += 1;
}//end if
//step 1, first player
if ($step == 1)
{
echo "Player 1";
// Loop through the alphabet from a to j and stop before k on this for loop
for ($i = a; $i < k; $i++)
{
// Print out the table with the letters from a to j using the variable $i
echo "<tr><td width='20' align='right'>$i</td>";
// Loop through the numbers for $j using numbers from 1 to less than 11 which is 10;
for ($j = 1; $j < 11; $j++)
{
echo "<td><input type='submit' value='fire' name='$i$j'></td>";
}
// end for loop
echo "</tr>";
}
// end for loop
echo "<tr><td></td>";
for ($j = 1; $j < 11; $j++)
{
echo "<td>$j</td>";
}
echo "</tr></table>";
//step 2 result of first player fire
}
else if($step == 2)
{
echo "Result 1";
for ($i = a; $i < k; $i++)
{
echo "<tr><td width='20' align='right'>$i</td>";
for ($j = 1; $j < 11; $j++){
//<input type="checkbox" name="state[]" value="NE">
echo "<td><input type='checkbox' type='submit' checked='checked' name='$i$j'></td>";
} // end for loop
echo "</tr>";
} // end for loop
echo "<tr><td></td>";
for ($j = 1; $j < 11; $j++){
echo "<td>$j</td>";
}
echo "</tr></table><br><input type='submit' name='' value='Player 2 Turn'>";
//step 3 second player fireing
} else if($step == 3) {
echo "Player 2";
for ($i = a; $i < k; $i++){
echo "<tr><td width='20' align='right'>$i</td>";
for ($j = 1; $j < 11; $j++){
echo "<td><input type='submit' value='fire' name='$i$j'></td>";
} // end for loop
echo "</tr>";
} // end for loop
echo "<tr><td></td>";
for ($j = 1; $j < 11; $j++){
echo "<td>$j</td>";
}
echo "</tr></table>";
//step 4 result of second player fire
} else {
echo "Result 2 ";
for ($i = a; $i < k; $i++){
echo "<tr><td width='20' align='right'>$i</td>";
for ($j = 1; $j < 11; $j++){
echo "<td><input type='checkbox' checked='checked' disabled='disabled' name='$i$j'></td>";
} // end for loop
echo "</tr>";
} // end for loop
echo "<tr><td></td>";
for ($j = 1; $j < 11; $j++){
echo "<td>$j</td>";
}
echo "</tr></table><br><input type='submit' name='' value='Player 1 Turn'>";
}//end if
for ($j = 1; $j < 11; $j++){
if ($checked){
echo "<td><input type='checkbox' checked='checked' name='variable'></td>";
} else {
echo "<td><input type='checkbox' name='variable'></td>";
}
}
?>
<input type="hidden" name="step" value="<?php echo "$step"; ?>"
</form>
</center>
</html>
你有什么确切的问题? – Ikke 2009-11-16 12:21:58
听起来有点太“为我做我的工作”......描述:1.应该发生什么? 2.哪种方式不会发生?然后,将您的代码编写到您认为重要的部分,然后询问您想问 – 2009-11-16 12:23:57