Jump to content

select & delete database rows


kraadde

Recommended Posts

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]
<?php


error_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;">
 
<?php

echo '<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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.