und wie mach ich das?
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
funktioniert nicht.
Script sieht jetzt so aus:
if($_GET['clear']) mysql_query("DELETE FROM newsarchiv WHERE id = $_GET[clear]",$dp);
if ($_GET['edit'])
{
if ($_POST['submit'])
{
$sql = "UPDATE newsarchiv SET
username='$_POST[username]',
titel='$_POST[titel]',
news='$_POST[news]'
WHERE id = $_GET[edit]";
$result = mysql_query($sql,$dp);
}
else
{
$sql = "SELECT * FROM newsarchiv WHERE id = $_GET[edit]";
$result = mysql_query($sql,$dp);
$data = mysql_fetch_array($result);
?>
<form method="post" action="<? echo $PHP_SELF ?>">
<input type="hidden" name="edit" value="<? echo $data["id"] ?> ">
<table border="0" align="center">
<tr><td>Username</td><td>
<input type="text" name="username" value="<? echo $data["username"] ?>" size="50">
</td></tr><tr><td>Titel</td><td>
<input type="text" name="titel" value="<? echo $data["titel"] ?>" size="99">
</td></tr><tr><td>News</td><td>
<textarea name="news" cols="75" rows="19" ><? echo $data["news"] ?></textarea>
</td></tr>
<tr><td> </td><td>
<input type="submit" name="submit" value="Ändern">
</td></tr></table>
</form>
<?
}
}
$result = mysql_query("SELECT * FROM newsarchiv",$dp);
?>
<form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
funktioniert nicht.
Script sieht jetzt so aus:
if($_GET['clear']) mysql_query("DELETE FROM newsarchiv WHERE id = $_GET[clear]",$dp);
if ($_GET['edit'])
{
if ($_POST['submit'])
{
$sql = "UPDATE newsarchiv SET
username='$_POST[username]',
titel='$_POST[titel]',
news='$_POST[news]'
WHERE id = $_GET[edit]";
$result = mysql_query($sql,$dp);
}
else
{
$sql = "SELECT * FROM newsarchiv WHERE id = $_GET[edit]";
$result = mysql_query($sql,$dp);
$data = mysql_fetch_array($result);
?>
<form method="post" action="<? echo $PHP_SELF ?>">
<input type="hidden" name="edit" value="<? echo $data["id"] ?> ">
<table border="0" align="center">
<tr><td>Username</td><td>
<input type="text" name="username" value="<? echo $data["username"] ?>" size="50">
</td></tr><tr><td>Titel</td><td>
<input type="text" name="titel" value="<? echo $data["titel"] ?>" size="99">
</td></tr><tr><td>News</td><td>
<textarea name="news" cols="75" rows="19" ><? echo $data["news"] ?></textarea>
</td></tr>
<tr><td> </td><td>
<input type="submit" name="submit" value="Ändern">
</td></tr></table>
</form>
<?
}
}
$result = mysql_query("SELECT * FROM newsarchiv",$dp);
?>
Kommentar