Sprits
Legacy Member
PHP:
<?php session_start(); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body bgcolor="999999">
<div align="right"><a href="admin.php" target="_blank">Administratie Paneel</a></div>
<?php
if (isset($_SESSION["username"]))
{
echo("<div align='left'>Klik <a href='logout.php'>hier</a> om u uit te loggen.</div>");
}
?>
<?php
include ('connect.php');
$query = "SELECT * FROM newses ORDER BY id desc limit 5";
$result = mysql_query($query) or die(mysql_error());
while(list($id,$titel,$nieuws)= mysql_fetch_row($result))
{
?>
<table width=100% border="0" bgcolor="#999999">
<tr>
<td width="100" valign="top">ID: </td>
<td align="left" valign="top"><?php echo("$id");?> </td>
<?php if (isset($_SESSION["username"]))
{
echo('<td align="right" width="50" valign="top"><a href="bewerken.php?id=[$id]"><img src="button_edit.png"></a></td>');
}
?>
</tr>
<tr>
<td width="100" valign="top">Titel : </td>
<td align="left" valign="top"><?php echo("$titel");?></td>
</tr>
<tr>
<?php $bericht=nl2br($nieuws); ?>
<td width="100" height="100" valign="top">Bericht : </td>
<td align="left" valign="top"><?php echo("$bericht");?></td>
</tr>
<tr>
<td colspan="3"><hr align="center" width=90%></td>
</tr>
</table>
<?php
}
?>
</body>
</html>
bij <a href="bewerken.php?id=[$id]"> vult die in plaats van een nummer gewoon [$id]... is er mss iets verkeerd in de code ofzo?
Ik ben nog ma juist bezig me PHP en het is de bedoeling een nieuwscriptje te make... Als ik het linkje zelf aanpas in mijn browser naar een ID dan kan ik het bewerken en gaat alles goed!
dit is mijn bewerken.php
PHP:
<?php
include("connect.php");
if (isset($_POST["bevestiging"]))
{
$query = "Update newses SET
titel = '". $_POST["titel"] ."',
nieuws = '". $_POST["nieuws"] ."',
where id='" .$_POST["id"] ."'";
$res = mysql_query($query) or die (mysql_error());
if ($res)
{
echo("Het nieuws is aangepast<br>");
echo("<a href='index.php'>Ga terug</a>");
}
}
else
{
$query = "Select * from newses where id='" . $_GET["id"]."'";
$res = mysql_query($query) or die (mysql_error());
?>
<html>
<head><title>Bewerken</title></head>
<body>
<h2>Bewerken</h2>
<?php
while (list($id, $titel, $nieuws) = mysql_fetch_row($res))
{
$ti=$titel;
$ni=$nieuws;
}
?>
<form action="<?php echo($SERVER["PHP_SELF"]);?>" method="post">
<input type="hidden" name="bevestiging" value="1">
<input type="hidden" name="nummer" value="<?php echo($_GET["id"]);?>">
Titel:<input type ="text" name="titel" value="<?php echo($ti);?>" size="30"><br>
Bericht:<TEXTAREA NAME="nieuws" ROWS="4" COLS="50" wrap="hard"><?php echo($ni);?></TEXTAREA><br>
<hr>
<input type="Submit" value="Bijwerken">
<input type="button" value="Terug" onClick="javascript:history.back();">
</form>
<?php
}
?>
</body>
</html>
.