html - PHP - checkbox form wont return itself as clicked -


i have variable called present, have checkbox, need make if checkbox checked, submits form, $present variable change value of 1. right nothing happens if box checked, if change from

if(isset($_post['stud_attendance'])) 

to

if(!isset($_post['stud_attendance'])) 

then work, because else sets $present variable one, reason code isn't realizing checkbox checked.

below code:

$present = 1;  while($row = mysqli_fetch_row($result)) {      echo "<tr>";      echo "<td>".$row[0]."</td>";      echo "<td>";      echo $row[6];      ?>   //below code****************************************************      <input type="checkbox" name="stud_attendance" value="0">      <?php      if(isset($_post['stud_attendance'])) { $present = 1; } else {   $present = 0;  }  // above code ******************************      echo $present; // above check value of variable     echo "</td>";      echo "<td>".$row[2]."</td>";      echo "<td>".$row[3]."</td>";      echo "<td>".$row[4]."</td>";      echo "<td>".$row[5]."</td>";      echo "<td>".$row[1]."</td>";      echo "</tr>";  }  echo "</table>"; 

you use javascript, in submit input:

onclick="if(this.value=='0') this.value='1'" 

but input should surrounded form.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -