我想使它選擇框用戶選擇保持選擇包裝驗證失敗後在我的形式其餘的表單工作完美,但我似乎無法數字如何對於選擇框做到這一點不改變所有的名字能有人幫我創造了這個包含只是我的表單複選框,我將在稍後做出相應的動作,所以你可以看到我需要如何選擇用戶選中的複選框如果幾個具有相同的名稱php
<form id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div id="desert_l">
<label for="hnumber"><div class="bookerror"></div>Desert Choice </label>
</div>
<div id="desert_f">
<table width="275">
<tr>
<td width="113">
<label>
<input type="checkbox" name="desgroup[]" value="Vanila Cheesecake"<?php if (isset($dessgroup) && ($dessgroup == "Vanila Cheesecake"))
{
echo ' checked="checked""';
}
?> />
Vanilla Cheesecake</label></td>
<td width="94"><input type="checkbox" name="desgroup[]" value="Carrot Cake"<?php if (isset($dessgroup) && ($dessgroup == "Carrot Cake"))
{
echo ' checked="checked""';
}
?> />
Carrot Cake</td>
<td width="52"><input type="checkbox" name="desgroup[]" value="Jelly"<?php if (isset($dessgroup) && ($dessgroup == "Jelly"))
{
echo ' checked="checked""';
}
?> />
Jelly</td>
</tr>
<tr>
<td><label>
<input type="checkbox" name="desgroup[]" value="Fruit Cheesecake"<?php if (isset($dessgroup) && ($dessgroup == "Fruit Cheesecake"))
{
echo ' checked="checked""';
}
?> >
Fruit Cheesecake</label></td>
<td><input type="checkbox" name="desgroup[]" value="Fruit Flan"<?php if (isset($dessgroup) && ($dessgroup == "Fruit Flan"))
{
echo ' checked="checked""';
}
?> />
Fruit Flan</td>
<td> </td>
</tr>
<tr>
<td><label>
<input type="checkbox" name="desgroup[]" value="Fruit Platter"<?php if (isset($dessgroup) && ($dessgroup == "Fruit Platter"))
{
echo ' checked="checked""';
}
?> />
Fruit Platter</label></td>
<td><input type="checkbox" name="desgroup[]" value="Chocolate Cake"<?php if (isset($dessgroup) && ($dessgroup == "Chocolate Cake"))
{
echo ' checked="checked""';
}
?>/>
Chocolate Cake</td>
<td> </td>
</tr>
</table>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
<p><span class="bookerror">
<?php
$dessgroup = $_POST['desgroup'] ;
if (isset ($_POST['submit']))
{
if (isset ($dessgroup))
{
echo "<h2>Desert Choice</h2>";
// Show Deserts Selected
for($i=0; $i < count($dessgroup); $i++)
{
echo $dessgroup[$i]."</br>";
}}
else
{
echo "You Must Select At Least 1 Desert" ;
}
}
?>
</span></p>
<p>Please Choose The Number Specified In Your Menu Choice<br />
</p>
</div>
</form>
您可以使用[** **會話(http://www.php.net/manual/en/features.sessions.php)對於這一點,那麼只需使用條件語句並對其進行回顯即可。 –