具有不同选项选择的Php / Html表单

时间:2015-05-18 11:55:36

标签: php html

我的php和html编码是:

$damt2 = isset($_POST['damt2']) ? $_POST['damt2'] : 200;
$dateinfo2 = json_decode(file_get_contents($_SESSION['base_path'] . 'dl.dict'), true);
arsort($dateinfo2); //arsort — Sort an array in reverse order and maintain index association
$dateinfo2 = array_slice($dateinfo2, 0, $damt2); //array_slice — Extract a slice of the array

<input type="hidden" name="userId" value="<?= $_SESSION['userId']; ?>">
<select name="damt2" onchange="this.form.submit()">
<option value="50" <?= (isset($damt2) & $damt2 == 50) ? 'selected' : ''; ?>>50</option>
<option value="100" <?= (isset($damt2) & $damt2 == 100) ? 'selected' : ''; ?>>100</option>
<option value="200" <?= (isset($damt2) & $damt2 == 200) ? 'selected' : ''; ?    >>200</option>

<input name="radio" type="radio" value="cow">Cow
<input name="radio" type="radio" value="chicken">Chicken
</select>  <input type="submit" name="submit" value="Show List & Save">

<?php    
    foreach ($dateinfo2 as $key => $time){
    $uInfo = $_SESSION['data']->table('units')->byName($key)->data();
    if ($uInfo["keyword"] != 'chicken') continue;
    if ($uInfo["keyword"] != 'cow') continue;
    if (isset($uInfo['type']) && !empty($uInfo['type'])) {
        echo '<center><font color="olive">TypE: '.$uInfo['type'].'</font><br>';
    }else{
    }
}
?>

为什么结果全部空白?

我想我在哪里做错了: 在foreach循环中,两个值都继续。 在带有单选按钮的类别选择中。

我希望表格有两个选项(一个搜索号为50,100,200),第二个类别为“牛”和“鸡”。

1 个答案:

答案 0 :(得分:3)

我的问题现在已解决,我通过阅读互联网上的几篇帖子来做到这一点,最后我尝试了:

在HTML部分:

RESULT_OK

PHP编码:

<input name="cow" type="radio" >Cow
<input name="chicken" type="radio" >chicken

在结果中,我有两个单选按钮和下拉菜单来选择愿望类别(鸡/牛)的结果长度(50,100,200..etc)。 谢谢大家试图支持我的建议。祝所有人感到美好 ^ _ ^