kraadde Posted January 13, 2007 Share Posted January 13, 2007 what I wanna to achieve is to have a set of database records listed in a table with a column with checkboxes. the user should be able to tick some checkboxes and by pushing a bitton, delete the corresponding records in the database and in the displayed table.I tried some coding and below is what I did. however there are always error messages like:Undefined index: ...and implode() [function.implode]: Bad arguments.I tried alsmost everything, but I need fresh eyes to look at it...Any help from you guys please...What I am doing wrong or is ther any better way to achieve what i want? anyone knows a script of some sort?Many thanks[email protected][code]<?phperror_reporting(E_ALL); // dB Initiali include("connect.inc.php");// ms into min, sec include ("msTominsec_Umw.php"); mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error()); mysql_select_db(DB_Login) or die(mysql_error());?> <table border="0" width="98%"rules="rows" > <tr> <td width="5%">#</td> ....more table code..... <td width="5%"></td> </tr></table><div style="width:98%; height:400px; overflow:auto; border:0px solid #840; margin:1em;"> <?phpecho '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST">'; $res_wunsch = mysql_query("SELECT * FROM xxxx order by in_time"); while ($dsatz_wunsch = mysql_fetch_assoc($res_wunsch)) { echo "<table border='0' width='98%' rules='rows' >" . "<tr>" . "<td col width='5%' bgcolor='#FFFFFF'>" . $dsatz_wunsch["w_ID"]. "</td>" ........more data output....... . $dsatz_wunsch["in_time"]. "</td>" . "<td col width='24%' bgcolor='#FFFFFF'>" . $dsatz_wunsch["dedication"]. "</td>" . "<td col width='5%' bgcolor='#FFFFFF'>" . "<input type='checkbox' name='eint[]' value='" . $dsatz_wun['ID'] ."'>" . "</tr>" . "</table>"; } echo "<input type= 'submit' id='send' value='del'>" . "</form>";$dattz_ids = $_POST['eint']; // // query $query = "DELETE FROM xxxx WHERE" . " ID IN(" . implode(",", $dattz_ids) // . ")"; mysql_query($query) or die ("MySQL-error: " . mysql_error()); ?> </div>[/code] Link to comment https://forums.phpfreaks.com/topic/33978-select-delete-database-rows/ Share on other sites More sharing options...
play_ Posted January 13, 2007 Share Posted January 13, 2007 Check your page and look at the source code.I use hidden input fields and delete by ID Link to comment https://forums.phpfreaks.com/topic/33978-select-delete-database-rows/#findComment-159647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.