Jump to content

[SOLVED] help on news script


L

Recommended Posts

Hey,

I need help with my news script...i added comments so you can see what im trying to do.

But basically i have two files, the submitnews.php and the show.php. Submitnews.php is a separate file so i can submit news to the database

show.php shows the news article with the comments associated with it.

THE PROBLEM:

The News, user who submitted it, date, and the subject are all not showing. Only the comments are showing.

Thank you for your time

EDIT: Forgot to add the script...hehe...

show.php

<?PHP
include("db.php");
// Get News ID
$id = $_GET['id']; 
// Get the Actual News that matches the News ID
$news = mysql_fetch_array(mysql_query("SELECT * FROM `news` WHERE `id`=$id ") or die(mysql_error()));
// Get Comments for that specicif News ID
$comid = mysql_query("SELECT * FROM `comments` WHERE `newsid`='".$news['id']."' ORDER BY `id` DESC LIMIT 0,50") or die(mysql_error());
// Display News Artical
echo $news['news'];
echo $id;
?>
<table width="35%" cellspacing="2" cellpadding="2" border="2">
<tr>
<td> User </td><td> Comment </td>
</tr>
<?
// Set up an IP address that has access to delete comments
$ip = $_SERVER['REMOTE_ADDR'];
$okip = "24.15.10.41";
while ($view = mysql_fetch_array($comid)) {
// Display all comments for artical, with Delete Comment Option if your IP matches the OK IP
if ($ip == $okip) {
echo "<tr><td><a href=\"mailto:".stripslashes($view['contact'])."\">".stripslashes($view['user'])."</a><br>".$view['date']."<br><center><a href=\"show.php?del=".$view['id']."\">[X]</a></center></td><td><textarea name=\"textarea\" cols=\"25\" rows=\"4\" wrap=\"virtual\" readonly>".stripslashes($view['comment'])."</textarea></td></tr>";
}
// If it doesn't match it, display comments without delete option
else {
echo "<tr><td><a href=\"mailto:".stripslashes($view['contact'])."\">".stripslashes($view['user'])."</a><br>".$view['date']."</td><td><textarea name=\"textarea\" cols=\"25\" rows=\"4\" wrap=\"virtual\" readonly>".stripslashes($view['comment'])."</textarea></td></tr>";
}
}
?>
</table>
<?PHP
// This stuff is needed to delete the comment from the database
$comment = $_GET['del'];
if ($comment != NULL && is_numeric($comment)) {
  if ($ip == $okip) {
mysql_query("DELETE FROM `comments` WHERE `id` = '".$comment."' LIMIT 1 ");
echo "Comment has been deleted.<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"2; URL=show.php\"> ";
}
else {
echo "You do not have permission to delete comments."; }
}
?>

~L

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.