Thanks for the input, dalecosp. To be honest, I understood most of what you wrote, but not all of it. I'm not sure what you mean by a handler script.
I'm trying to figure this out but I can't seem to be able to create a delete script.
I will post the script that displays all of the stories (which works) and my delete script. I apologize in advance for the sloppy code. 🙂
This is the page where the story headings appear. When clicked on, it goes to the page that displays the story. I added a "Delete" link to the first category to test it out but it's not working.
<?php
require_once("connect.php");
?>
<?php
// Selects the fields that will be displayed
$query="SELECT news_ID,news_category_ID,news_title,news_story from news WHERE news_category_ID=1
ORDER BY news_ID DESC";
$result=mysql_query($query,$connect);
// This formats the table
echo "<table width=200, border=1, align='center'>\n";
echo "<tr><td bgcolor='red'>Sports</td></tr>";
// This writes the data that has been selected
for($i=0;$i<mysql_num_rows($result);$i++){
list($news_ID,$news_category_ID,$news_title)=mysql_fetch_row($result);
echo "<tr><td><a
href='showstory.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>$news_title</a><a
href='delete.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>Delete</a></td>\n";
}
// This closes the table
echo "</tr><tr><td bgcolor='red'> </td></tr>\n";
echo "</table>\n";
// Selects the fields that will be displayed
$query="SELECT news_ID,news_category_ID,news_title,news_story from news WHERE news_category_ID=2
ORDER BY news_ID DESC";
$result=mysql_query($query,$connect);
// This formats the table
echo "<table width=200, border=1, align='center'>\n";
echo "<tr><td bgcolor='red'>Entertainment</td></tr>";
// This writes the data that has been selected
for($i=0;$i<mysql_num_rows($result);$i++){
list($news_ID,$news_category_ID,$news_title)=mysql_fetch_row($result);
echo "<tr><td><a
href='showstory.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>$news_title</a></td>\n";
}
// This closes the table
echo "</tr><tr><td bgcolor='red'> </td></tr></table>\n";
// Selects the fields that will be displayed
$query="SELECT news_ID,news_category_ID,news_title,news_story from news WHERE news_category_ID=3
ORDER BY news_ID DESC";
$result=mysql_query($query,$connect);
// This formats the table
echo "<table width=200, border=1, align='center'>\n";
echo "<tr><td bgcolor='red'>News</td></tr>";
// This writes the data that has been selected
for($i=0;$i<mysql_num_rows($result);$i++){
list($news_ID,$news_category_ID,$news_title)=mysql_fetch_row($result);
echo "<tr><td><a
href='showstory.php?news_ID=$news_ID&news_category_ID=$news_category_ID'>$news_title</a></td>\n";
}
// This closes the table
echo "</tr><tr><td bgcolor='red'> </td></tr>\n";
echo "</table>\n";
mysql_close($connect);
?>
<br>
<center><a href="addnews.php">Add a story</a></center>
This is the delete script. I commented out certain lines. I'm not sure if I need them or not.
<?php>
require_once("connect.php");
//if($_GET['news_ID']){
// $_SESSION['news_ID']=$_GET['news_ID'];
//$_SESSION['news_category_ID']=$_GET['news_category_ID'];
//}
//if($_GET['submit']==true) {
$query = "DELETE FROM news WHERE news_ID = $_GET['news_ID']";
$result=mysql_query($query,$connect);
?>
I know I'm probably making some really stupid mistakes and overlooking things.