Nieuw lid |
|
Het is zo dat ik een lijst krijg met data uit mijn database. Deze data wordt weergegeven in een lijst met bewerkbare velden. Als ik op delete druk van bijv rij 1, dan word de laatste entry verwijderd, ipv diegene die ik heb geselecteerd.
hieronder heel mijn pagina:
<?php
ob_start();
?>
<?php
require "../db.php";
if (!isset($_SESSION["usernaam"]))
die("Sorry. U bent niet gemachtigd of ingelogd om deze pagina te bekijken.");
?>
<?php
if ($_POST["delete"] && $_POST["deleteID"])
{
mysql_query("DELETE FROM agendapunten WHERE ID={$_POST["deleteID"]}")
or die("Query heeft gefaald: " . mysql_error());
echo "<br><strong>Het agendapunt is verwijderd!</strong><br> <br>";
}
if ($_POST["Submit_update"])
{
$res=mysql_query("SELECT * FROM agendapunten ORDER BY volgorde")
or die("Query heeft gefaald: " . mysql_error());
while ($row=mysql_fetch_assoc($res))
{
mysql_query("UPDATE agendapunten SET text='".$_POST["text_{$row["ID"]}"]."' WHERE ID={$row["ID"]}") or die("Query heeft gefaald: " . mysql_error());
mysql_query("UPDATE agendapunten SET titel='".addslashes($_POST["titel_{$row["ID"]}"])."' WHERE ID={$row["ID"]}") or die("Query heeft gefaald: " . mysql_error());
mysql_query("UPDATE agendapunten SET volgorde='".addslashes($_POST["volgorde_{$row["ID"]}"])."' WHERE ID={$row["ID"]}") or die("Query heeft gefaald: " . mysql_error());
//else mysql_query("UPDATE agendapunten SET text=' ' WHERE ID={$row["ID"]}");
//echo mysql_query("UPDATE agendapunten SET text='".addslashes($_POST["text_{$row["ID"]}"])."' WHERE ID={$row["ID"]}");
}
}
?>
<?php
//Als men op Submit gedrukt heeft
if ($_POST['Submit_new']) {
//We maken een query en voeren die uit door mysql_query()
$query="INSERT INTO agendapunten (titel, text, volgorde)
VALUES ('$_POST[titel]', '$_POST[text]','$_POST[volgorde]')";
mysql_query ($query) or die (mysql_error());
?>
<link href="styleGL.css" rel="stylesheet" type="text/css" />
<center>
<form name="agenda" action="" method="post">
<p> </p>
<table class="agenda" width="95%" border="1" cellspacing="0" cellpadding="2">
<tr background="images/web/balk.jpg">
<td height="20" colspan="2" class="menutitel" background="images/web/balk.jpg"><strong class="menutekst2">Kalenderitem aanmaken:</strong></td>
</tr>
<tr bgcolor="#8e8e8e">
<td colspan="2" align="center" class="text">
<p>Titel:
<input name="titel" type="text" class="login" id="titel" size="50" maxlength="50">
</p>
<p><br>
<textarea name="text" cols="50" rows="10" id="text"></textarea>
<br> <br>
<span class="tabeltekst">Volgorde ter verschijning:</span>
<input name="volgorde" type="text" class="login" id="volgorde" size="5" maxlength="5">
</p>
<p class="tabeltekst">maak een keuze van volgorde dmv 1, 2 , 3, ... in te vullen </p></td>
</tr>
<tr>
<td height="25" colspan="2" align="center" bgcolor="#8e8e8e">
<input type="submit" name="Submit_new" value="Verzenden">
<input name="Reset" type="submit" id="Reset" value="Opnieuw"> </td>
</tr>
</table>
</form>
</center>
<p>
<?php
//Als men nog niet op Submit gedrukt heeft krijgt men natuurlijk het formulier te zien
} else {
?>
</p>
<p> </p>
<center>
<form name="agenda" action="" method="post">
<table class="agenda" width="95%" border="1" cellspacing="0" cellpadding="2">
<tr background="images/web/balk.jpg">
<td height="20" colspan="2" class="menutitel" background="images/web/balk.jpg"><strong class="menutekst2">Kalenderitem aanmaken:</strong></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#8e8e8e" class="text">
<p><span class="tabeltekst">Titel:
</span>
<input name="titel" type="text" class="login" id="titel" size="50" maxlength="50">
</p>
<p><br>
<textarea name="text" cols="50" rows="10" id="text"></textarea>
<br> <br>
<span class="tabeltekst">Volgorde ter verschijning:</span> <input name="volgorde" type="text" class="login" id="volgorde" size="5" maxlength="5">
</p>
<p class="tabeltekst">maak een keuze van volgorde dmv 1, 2 , 3, ... in te vullen </p></td>
</tr>
<tr>
<td height="25" colspan="2" align="center" bgcolor="#8e8e8e">
<input type="submit" name="Submit_new" value="Verzenden">
<input name="Reset" type="submit" id="Reset" value="Opnieuw">
</td>
</tr>
</table>
</form>
</center>
<?php
}
?>
<script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
// Theme options
theme_advanced_buttons1 : "/save,/newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,/styleselect,/formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,/anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "/insertlayer,/moveforward,/movebackward,/absolute,/|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Example content CSS (should be your site CSS)
content_css : "../stijldewit.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "js/template_list.js",
external_link_list_url : "js/link_list.js",
external_image_list_url : "js/image_list.js",
media_external_list_url : "js/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>
<p> </p>
<p align="center" class="algemeen">De huidige agendapunten: </p>
<div align="center" class="algemeen">
<form method='post' action='index.php?inh=kalenderedit'>
<?php
{$res=mysql_query("SELECT * FROM agendapunten ORDER BY volgorde")
or die("Query heeft gefaald: " . mysql_error());
$out="<table width=85% height=0 border=0 class='tabeltekst' align=left>";
while ($row=mysql_fetch_assoc($res))
{
$titel="<input type='text' class='login' name='titel_{$row["ID"]}' size='40' value='{$row["titel"]}'>";
$volgorde="<input type='text' class='login' name='volgorde_{$row["ID"]}' size='3' value='{$row["volgorde"]}'>";
$text="<textarea cols='50' class='login' name='text_{$row["ID"]}'>{$row["text"]}</textarea><br>";
$verwerken="<input type='submit' name='Submit_update' value='Update'>";
$del="<input type='submit' name='delete' value='Delete'><input type='hidden' name='deleteID' value='{$row["ID"]}'></form>";
$out.="<td align='middle'>{$row["ID"]}</td>"
."<td align='left'><strong>Titel:</strong> $titel<br>
<strong>Volgorde:</strong>$volgorde<br>
<strong>Tekst:</strong>$text<br>
$verwerken $del<p><hr></td>"
."</tr>";
}
$out.="</table>";
$out.="<input type='hidden' name='page' value='kalenderedit'>";
//$out.="$verwerken";
echo $out;}
mysql_free_result($res);
?>
<?php ?> <?php require "../db.php"; if (!isset($_SESSION["usernaam"])) die("Sorry. U bent niet gemachtigd of ingelogd om deze pagina te bekijken."); ?> <?php if ($_POST["delete"] && $_POST["deleteID"]) { mysql_query("DELETE FROM agendapunten WHERE ID={$_POST["deleteID "]}") echo "<br><strong>Het agendapunt is verwijderd!</strong><br> <br>"; } if ($_POST["Submit_update"]) { $res=mysql_query("SELECT * FROM agendapunten ORDER BY volgorde") { mysql_query("UPDATE agendapunten SET text='".$_POST["text_{$row["ID "]}"]."' WHERE ID={$row["ID "]}") or die("Query heeft gefaald: " . mysql_error()); //else mysql_query("UPDATE agendapunten SET text=' ' WHERE ID={$row["ID"]}"); //echo mysql_query("UPDATE agendapunten SET text='".addslashes($_POST["text_{$row["ID"]}"])."' WHERE ID={$row["ID"]}"); } } ?> <?php //Als men op Submit gedrukt heeft if ($_POST['Submit_new']) { //We maken een query en voeren die uit door mysql_query() $query="INSERT INTO agendapunten (titel, text, volgorde) VALUES ('$_POST[titel]', '$_POST[text]','$_POST[volgorde]')"; ?> <link href="styleGL.css" rel="stylesheet" type="text/css" /> <center> <form name="agenda" action="" method="post"> <p> </p> <table class="agenda" width="95%" border="1" cellspacing="0" cellpadding="2"> <tr background="images/web/balk.jpg"> <td height="20" colspan="2" class="menutitel" background="images/web/balk.jpg"><strong class="menutekst2">Kalenderitem aanmaken:</strong></td> </tr> <tr bgcolor="#8e8e8e"> <td colspan="2" align="center" class="text"> <p>Titel: <input name="titel" type="text" class="login" id="titel" size="50" maxlength="50"> </p> <p><br> <textarea name="text" cols="50" rows="10" id="text"></textarea> <br> <br> <span class="tabeltekst">Volgorde ter verschijning:</span> <input name="volgorde" type="text" class="login" id="volgorde" size="5" maxlength="5"> </p> <p class="tabeltekst">maak een keuze van volgorde dmv 1, 2 , 3, ... in te vullen </p></td> </tr> <tr> <td height="25" colspan="2" align="center" bgcolor="#8e8e8e"> <input type="submit" name="Submit_new" value="Verzenden"> <input name="Reset" type="submit" id="Reset" value="Opnieuw"> </td> </tr> </table> </form> </center> <p> <?php //Als men nog niet op Submit gedrukt heeft krijgt men natuurlijk het formulier te zien } else { ?> </p> <p> </p> <center> <form name="agenda" action="" method="post"> <table class="agenda" width="95%" border="1" cellspacing="0" cellpadding="2"> <tr background="images/web/balk.jpg"> <td height="20" colspan="2" class="menutitel" background="images/web/balk.jpg"><strong class="menutekst2">Kalenderitem aanmaken:</strong></td> </tr> <tr> <td colspan="2" align="center" bgcolor="#8e8e8e" class="text"> <p><span class="tabeltekst">Titel: </span> <input name="titel" type="text" class="login" id="titel" size="50" maxlength="50"> </p> <p><br> <textarea name="text" cols="50" rows="10" id="text"></textarea> <br> <br> <span class="tabeltekst">Volgorde ter verschijning:</span> <input name="volgorde" type="text" class="login" id="volgorde" size="5" maxlength="5"> </p> <p class="tabeltekst">maak een keuze van volgorde dmv 1, 2 , 3, ... in te vullen </p></td> </tr> <tr> <td height="25" colspan="2" align="center" bgcolor="#8e8e8e"> <input type="submit" name="Submit_new" value="Verzenden"> <input name="Reset" type="submit" id="Reset" value="Opnieuw"> </td> </tr> </table> </form> </center> <?php } ?> <script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript"> tinyMCE.init({ // General options mode : "textareas", theme : "advanced", plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", // Theme options theme_advanced_buttons1 : "/save,/newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,/styleselect,/formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,/anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "/insertlayer,/moveforward,/movebackward,/absolute,/|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "../stijldewit.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "js/template_list.js", external_link_list_url : "js/link_list.js", external_image_list_url : "js/image_list.js", media_external_list_url : "js/media_list.js", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); </script> <p> </p> <p align="center" class="algemeen">De huidige agendapunten: </p> <div align="center" class="algemeen"> <form method='post' action='index.php?inh=kalenderedit'> <?php {$res=mysql_query("SELECT * FROM agendapunten ORDER BY volgorde") $out="<table width=85% height=0 border=0 class='tabeltekst' align=left>"; { $titel="<input type='text' class='login' name='titel_{$row["ID"]}' size='40' value='{$row["titel"]}'>"; $volgorde="<input type='text' class='login' name='volgorde_{$row["ID"]}' size='3' value='{$row["volgorde"]}'>"; $text="<textarea cols='50' class='login' name='text_{$row["ID"]}'>{$row["text"]}</textarea><br>"; $verwerken="<input type='submit' name='Submit_update' value='Update'>"; $del="<input type='submit' name='delete' value='Delete'><input type='hidden' name='deleteID' value='{$row["ID"]}'></form>"; $out.="<td align='middle'>{$row["ID"]}</td>" ."<td align='left'><strong>Titel:</strong> $titel<br> <strong>Volgorde:</strong>$volgorde<br> <strong>Tekst:</strong>$text<br> $verwerken $del<p><hr></td>" ."</tr>"; } $out.="</table>"; $out.="<input type='hidden' name='page' value='kalenderedit'>"; //$out.="$verwerken"; ?>
|