Php / Html form with various options

my php and html coding:

$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

Table

<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{
    }
}
?>

Why is everything empty?

I think where I am wrong: In the foreach loop, both values ​​continue. Select a category using the switch.

I need a form with two options (one with a search number of 50,100,200) and a second with categories like "cow" and "chicken."

+4
source share
1 answer

My question is now resolved , and I did this by reading a few posts from around the Internet, and in the end I tried:

In the HTML section:

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

PHP coding:

<?php
 foreach ($dateinfo2 as $key => $time)
{
  $uInfo = $_SESSION['data']->table('units')->byName($key)->data();//item get data by name

  if(isset($_POST['cow'])){
    if ($uInfo["keyword"] != 'cow') continue;
}
  if(isset($_POST['chicken'])){
    if ($uInfo["keyword"] != 'chicken') continue;
}
if (isset($uInfo['type']) && !empty($uInfo['type'])) {
    echo '<center><font color="olive">TypE: '.$uInfo['type'].'</font><br>';
}else{
 }
}

, (50,100,200.etc) (/). , . ^ _ ^

+3

All Articles