Location: PHPKode > projects > AlkalinePHP > deletenewscomment.php
<?
include("identify.php");
load_all("deletenewscomment",0,1);


$table_name = "newscomments";
$sql = "
		SELECT *
		FROM $table_name
		WHERE id = $newscomment_id
		ORDER BY id DESC
	";

$result = @mysql_query($sql, $main_settings->connection) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
	$id = $row['id'];
	$news_owner = $row['news_owner'];
	$user_owner = $row['user_owner'];
	$owner_name = $row['owner_name'];
	$content = $row['content'];
	$date = $row['date'];
}

if ( ($user_owner == $main_user->id) || ($main_user->level >= 5) ) {
	$sql = "DELETE FROM $table_name WHERE id = \"$newscomment_id\"";
	$result = @mysql_query($sql, $main_settings->connection) or die("Couldn't execute query.");

	$table_name = "articles";

	$sql = "
		SELECT *
		FROM $table_name
		WHERE id = $news_owner
		ORDER BY id DESC
	";

	$result = @mysql_query($sql, $main_settings->connection) or die("Couldn't execute query.");
	while ($row = mysql_fetch_array($result)) {
		$title = $row['title'];
		$comments = $row['comments'];
	}
	$comments = $comments - 1;
	$sql = "UPDATE $table_name
		SET
		comments = \"$comments\"
		WHERE id = \"$news_owner\"
	";
	$result = @mysql_query($sql, $main_settings->connection) or die("Couldn't execute query.");

	header ("Location: article.php?news_id=$news_owner");

} else {
	$msg = "You do not have permission to delete this comment.<br><br>";
}
?>
Return current item: AlkalinePHP