Prøver at ændre i news script lavet af schaefner
I dette script kan skrive kommentar til nyheder, jeg vil gerne kunne slette disse kommentar ude at slette hele nyheden,har sat noget ekstra kode ind i news_edit.php men kan ikke rigtig få det til at virke, en demo kan se og bruges på http://www.dansk-radio.dk/news/
Pls. help
<?php
include_once('inc.limited_access.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../stylesheet.css">
</head>
<body>
// Indlæser for at kunne rette i nyheder
<?php
include_once('../config/inc.config.php');
$query = mysql_query("SELECT * FROM news WHERE id=".$_GET['id']."") or die(mysql_error());
$row = mysql_fetch_assoc($query);
?>
<h1>Administration : Rediger nyhed</h1>
<form method="post" action="form.handle.php">
<input type="hidden" name="referer" value="edit_news">
<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">
<input type="hidden" name="offset" value="<?php echo $_GET['offset']; ?>">
<div class="frmobj">Overskrift</div> <input type="text" name="title" value="<?php echo $row['title']; ?>" style="width: 300px"><br>
<div class="frmobj">Forfatter</div> <input type="text" name="author" value="<?php echo $row['author']; ?>" style="width: 300px"><br>
<div class="frmobj">Billede</div> <input type="text" name="image" value="<?php echo $row['image']; ?>" style="width: 300px"><br><br>
<div class="frmobj">Synopsis</div> <textarea name="synopsis" rows="5" cols="0" style="width: 300px"><?php echo $row['synopsis']; ?></textarea><br>
<div class="frmobj">Nyhed</div> <textarea name="text" rows="10" cols="0" style="width: 300px"><?php echo $row['text']; ?></textarea><br><br>
<div class="frmobj"> </div> <input type="submit" value="Send">
</form>
<br><br>
// læser ind comments
<?php
$query = mysql_query("SELECT *,DATE_FORMAT(date,'%e/%c-%y %T') AS date FROM comments WHERE parent=".$_GET['id']." ORDER BY id ASC");
if (mysql_num_rows($query) > 0) {
echo '<h2>Kommentar</h2>';
while ($row = mysql_fetch_assoc($query)) {
echo empty($row['email']) ? htmlspecialchars($row['name']) : '<a href="mailto:'.$row['email'].'">'.htmlspecialchars($row['name']).'</a>';
echo ' ('.$row['date'].')<br><br>';
echo nl2br(htmlspecialchars($row['text']));
echo '<div class="hr"></div>';
}
}
?>
// Læser ind for at kunne slette comments
<?php
if (isset($_GET['deleteID'])) {
mysql_query("DELETE FROM comments WHERE id=".$_GET['deleteID']."") or die(mysql_error());
}
// det er jeg indlæser for at DELETE
$query = mysql_query("SELECT * FROM comments where parent=".$_GET['id'].($offset >= $cfg['limit'])."") or die(mysql_error());
echo '<ul>';
while ($row = mysql_fetch_assoc($query))
{
echo '<li>[<a href="?offset='.$offset.'&deleteID='.$row['id'].'">Slet Kommentar</a>] ';
echo $row['text'].'</li>';
}
// her kommer nogle linier jeg nok ikke bruger
echo '</ul>';
echo ($offset >= $cfg['limit']) ? '<a href="?offset='.($offset-$cfg['limit']).'">Forrige</a> ' : 'Forrige ';
for ($start=$start_point;$start<$end_point;$start=$start+$cfg['limit']) {
echo ($offset == $start) ? '<b>'.$page_number++.'</b> ' : '<a href="?offset='.$start.'">'.$page_number++.'</a> ';
}
echo ($total > $offset+$cfg['limit']) ? '<a href="?offset='.($offset+$cfg['limit']).'">Næste</a>' : 'Næste';
?>
<br><br>
<div class="hr"></div>
<a href="http://schaefner.dk" class="author">schaefner|dk</a> <a href="administration.php">Administration</a> | <a href="index.php?f=loggedout">Log ud</a>
<br><br><br>
</body>
</html>