-1

I have a table which is having checkbox for each column as shown below:

enter image description here

code for this table:

'<form action="ecfcoursedata.php" method="post">';
"<table width='50%'>";
'<tr><th>e-Competence Level</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th></tr>';  
  foreach ($tree as $key => $term) {
    '<tr><td>' . $term->name . '</td>'
    for($i=1; $i<=5; $i++) {
      '<td><input type="checkbox" name=' . $term->name . '-' . $i . '></td>';
    }
    '</tr>';
  }
 '</table></div>';
 '<div class="ecf-submit"><input type="submit" value="Submit" name=' . $arg0 . '></div></form>';

When I click on the submit I need checked value for each row and particular column. How I can achive that?Please help me in this regard.

Suraj
  • 297
  • 3
  • 18
  • Possible duplicate of [How to get value of checkbox in table?](https://stackoverflow.com/questions/30800228/how-to-get-value-of-checkbox-in-table) – Michel Nov 22 '18 at 11:53
  • Post your code. – Shubham Pokhriyal Nov 22 '18 at 11:55
  • 2
    You need to do the proper research and make some attempts. If you then get stuck on something _specific_ with your _existing_ code, then come back, show us what you've tried, expected result and what result you're getting. Currently, this question is too unspecific and broad. – M. Eriksson Nov 22 '18 at 12:01
  • 1
    you just need to run a `foreach ($tree as $key => $term)` on your ecfcoursedata.php file then check the value of `$_POST[$term->name.'-'.$i]` inside a `for` loop of 1-5 – Shubham Pokhriyal Nov 22 '18 at 12:08

1 Answers1

0

In your HTML suppose it's

<input type="checkbox" name="test" value="value1">

When you submit to php you can use

isset($_POST['test']);

or

if ($_POST['test'] == 'value1'){}

or

$variable = $_POST['test'];
Mulham Aryan
  • 180
  • 1
  • 3
  • 19