i having trouble deleting the selected checkbox... can someone help me with this?? i think it neds a javascript to check all the selected.. please help me with these,..
thanks...
thanks...
| Code: |
| <input type="checkbox" name="commentnotify" checked>Comment Notification<br /> |
| glena wrote: |
| this is what i men for exmple i have 5 checkboxes:
_john *philip _edwin *mark _leo i check philip and mark and press the button delete.. i tried it but only philip was deleted. how can i delete those two that i checked an if i check the check all how can i force all to have check and delete all? please help me with this.. |
| Code: |
| <?php
session_start(); if(@$_SESSION['phil'] == "checked") { $phil = ""; } else { $phil = "Phil: <input type=\"checkbox\" name=\"phil\" value=\"checkbox\" />"; } if(@$_SESSION['john'] == "checked") { $john = ""; } else { $john = "John: <input type=\"checkbox\" name=\"john\" value=\"checkbox\" />"; } if(@$_SESSION['edwin'] == "checked") { $edwin = ""; } else { $edwin = "Edwin: <input type=\"checkbox\" name=\"edwin\" value=\"checkbox\" />"; } ?> |
| Code: |
| <form name="form1" method="post" action="delete.php">
<?php echo $phil . "<br />" . $john . "<br />" . $edwin; ?> <br /> <input type="submit" name="delete" value="Delete" /> </form> |
| Code: |
| <?php
session_start(); $return = "whereIsForm.php"; foreach($_POST as $key => $val) { if($val == "checkbox") { $_SESSION[$key] = "checked"; } } header("Location:$return"); exit; ?> |
| Quote: |
| how about when you want to check all the checkbox?? do you have a code?? i think its a javascript but i dont know how to combine the two |
| Quote: |
| how can i do that?? please help me... and if i want to put check all how can i code it? |
| Quote: |
| i want to have a select all checkbox when i check it all the other checkbox will be check and then when i click the delete button it will delete all from the data base. |
| Code: |
| <table width = '100%'>
<?php $con = mysql_connect("localhost","root","") or die(mysql_error()); $dbsae = mysql_select_db("contacts"); $sql_query = "SELECT * from tinfos"; $result = mysql_query($sql_query); while($row = mysql_fetch_array($result)){ ?> <form id="form" name="form" method="post" action="deletecontacts.php"> <tr> <td><b> <?php echo $row['fname'] ?> </td> <td><b> <?php echo $row['lname'] ?> </td> <td><b> <?php echo $row['dobm'] ?> </td> <td><b> <?php echo $row['dobd'] ?> </td> <td><b> <?php echo $row['doby'] ?> </td> <td><b> <?php echo $row['gender'] ?></td> <td><b> <?php echo $row['pnum'] ?> </td> <td><b> <input type="checkbox" name="check[]" id="check[]" value="<?php echo $row['fname'] ?>"/> </td> <?php } ?> <input name="delete" type="submit" value="delete" /> </form></tr> </table> |
| Code: |
| <?php
$connum = $_GET['connum']; $con = mysql_connect("localhost","root","") or die(mysql_error()); $dbase = mysql_select_db("contacts"); $sql = "SELECT * from tinfos"; $result = mysql_query($sql); $num = mysql_num_rows($result); $delete = $_POST['delete']; $check = $_POST['check']; for ($a = 0; $a <= $num; $a++) { $del_fname = $check[$a]; $del = "DELETE from tinfos WHERE fname = '$del_fname'"; $result = mysql_query($del); if ($result) { header('location: showcontacts.php'); } else { die(mysql_error()); } } ?> |