A table is displayed containing filtered records from a MySQL dB. on the right of each record there is a checkbox for the user to select which record has to be deleted. A button on the bottom should start deleting the records and display a fresh table.
I have it donloaded on following [www.playbad.devide.ch/Wunsch_liste.php]. What I am getting is always Error messages and I could not find a solution for the problem:
Notice: Undefined index: eintrag in ....
Warning: implode() [function.implode]: Bad arguments. ...
I tried everything, but I might have overlooked something. Anyone can give me a hint?
kraadde
kraadde@yahoo.com
Code: Select all
<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 wunsch_in order by in_time");
// ID, w_ID, w_artist, w_title, w_duration, hoerer, dedication, in_time
/* Anzahl Datensätze ermitteln und ausgeben */
$num_wunsch = mysql_num_rows($res_wunsch);
echo "$num_wunsch Musikwünsche gefunden<br>";
echo "<br>";
/* Datensätze aus Ergebnis ermitteln, */
/* in Array speichern und ausgeben */
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>"
. "<td col width='15%' bgcolor='#FFFFFF'>"
. str_replace("\'", "'",$dsatz_wunsch["w_artist"]). "</td>"
. "<td col width='15%' bgcolor='#FFFFFF'>"
. str_replace("\'", "'", $dsatz_wunsch["w_title"]) . "</td>"
. "<td col width='6%' bgcolor='#FFFFFF'>"
// Umwandeln der Zeitangabe (Songdauer) von ms in minuten
. msTominsec($dsatz_wunsch["w_duration"]). "</td>"
. "<td col width='12%' bgcolor='#FFFFFF'>"
. $dsatz_wunsch["hoerer"]. "</td>"
. "<td col width='16%' bgcolor='#FFFFFF'>"
. $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='eintrag[]' value='" . $dsatz_wunsch['ID'] ."'>"
. "</tr>"
. "</table>";
}
echo "<input type= 'submit' name='eintrag' id='send' value='Löschen'>"
. "</form>";
$datensatz_ids = $_POST['eintrag']; // dies ist das array aller markierten einträge
$query = "DELETE FROM wunsch_in WHERE ID IN(".implode(",", $datensatz_ids) .")"; // so sieht der query zum
Löschen aus
?>
<?php
?>
</div>