php - I just can eliminate the last row from the database using checkboxes -


i have 1 html table rows value specific database table.

i created html table column eliminate specific row database, inside column exists checkbox check , eliminate multiple table rows database.

but i'm having problems, can delete last row, example: lets imagine check second row, , click @ submit button , nothing happens.

but if check last inserted row, , click submit, deletes row database.

i can delete last row, can't delete multiple rows checking specific number of checkboxes.

i did this:

example

i'm using mvc structure:

view:

<form method='post'> <?php echo "<td><input style='width: 50px;' class='delete' value='delete'  type='submit' name='del[]' /></td>";     foreach($editjoarray $key){         echo "     <table>     <tr>       <td> ".$key['id']."</td>        <td><input type='checkbox' name='delete[]' value=".$key['id']." /></td>     </tr>     </table>     </form>";      } 

model:

function fname(){  if(isset($_post['del']) && !empty($_post['delete'])) { {     $checkbox = $_post['delete'];     $countcheck = count($_post['delete']);  for($i=0;$i<$countcheck;$i++) { $del_id = $checkbox[$i];  echo $del_id;   $sql = "delete mytable id=$del_id";    $exe = mysql_query($sql) or die(mysql_error()); } } }      printfunction(); } 

you closing form tag inside loop there 1 delete checkbox (as post values). need move closing tag of form </form> outside loop checkboxes lies in same form.

<form method='post'> <?php foreach($editjoarray $key){        /*    delete checkboxes    input fields    */  } ?> </form> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -