S
S
shanik2018-01-30 20:53:50
PHP
shanik, 2018-01-30 20:53:50

How to output data in the right form depending on the conditions?

There is a checkbox habitat
When processing the form, data is sent: 0 or 1 If it is checked, then it should be displayed
5a70af9f9b66d982527829.png
in the loop; if it is not checked, then only this way $g->habitat
echo $g->date.' '.;

foreach ($group as $key => $g) {
     echo $g->date.' '.$g->habitat;
}

how can i do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima, 2018-01-31
Dolgoter @DDolgy

<form action="" method="post">
<input type="checkbox" name="habitat" value="habitat">
  
  
  <input type="submit">
</form>

<?php

if(isset($_POST['habitat'])){
$g = $_POST['habitat']; 	
  
}else{
$g = "не выбрано"; 	
}
   echo $g;
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question