<?php
include "config.php";
?>
<form method="post">
<table width="312" border="0">
<tr>
<td width="103">Groep:</td>
<td width="199"><select name="groepen" size="1">
<option value="do"> </option>
<?
$query = "SELECT * FROM Groepen";
$result = mysql_query($query);
while($rij = mysql_fetch_object($result)) {
$id = htmlspecialchars($rij->Groep_ID);
$naam = htmlspecialchars($rij->Groep_Naam);
echo "<option value=\"".$id."\">".$naam."</option>\n";
}
?></select></td>
</tr>
<tr>
<td> </td>
<td><input name="knop" type="submit" id="knop" value="Bewerken" onClick="<? Bewerken($_POST[groepen]) ?>" ></td>
</tr>
</table>
<?
function Bewerken($id)
{
if ($_POST["knop"])
{
$sql = "UPDATE Groepen SET Groep_Naam='".$_POST["Naam"]."', Groep_Datum_Ingang='".$_POST["ingang"]."', Groep_Datum_Einde='".$_POST["einde"]."' WHERE Groep_ID='$id'";
if (!mysql_query($sql))
{
echo "Helaas, ".$_POST["Naam"]." is niet gewijzigd.";
}
else
{
echo "".$_POST["Naam"]." is succesvol gewijzigd.</a>";
}
}
else
{
// Bewerkform
$sql2 = "SELECT * FROM Groepen WHERE Groep_ID='$id'";
$query = mysql_query($sql2); //voer SQL code uit
$rij = mysql_fetch_object($query);
$naam = htmlspecialchars($rij->Groep_Naam);
$ingang = htmlspecialchars($rij->Groep_Datum_Ingang);
$einde = htmlspecialchars($rij->Groep_Datum_Einde);
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"] ?>">
<table>
<tr>
<td>Naam:</td><td><input name="Naam" type="text" value="<?= $naam ?>" size="30" maxlength="50" /></td>
</tr>
<tr>
<td>Datum ingang:</td><td><input name="ingang" type="text" value="<?= $ingang ?>" size="30" maxlength="50" /></td>
</tr>
<tr>
<td>Datum einde:</td><td><input name="einde" type="text" value="<?= $einde ?>" size="30" maxlength="50" /></td>
</tr>
<tr>
<td><input type="submit" name="knop" value="Wijzigen"></font></td>
</tr>
</table>
</form>
<?
}
}
?>
[ignore]
[/ignore]-tags toegevoegd