Specifications

The delete story link calls delete_story.php, which actions a simple DELETE statement and
returns the writer to the calling page. The code for delete_story.php is shown in Listing
26.8.
LISTING 26.8 delete_story.php Is Used to Delete a Story From the Database
<?
// delete_story.php
include (“include_fns.php”);
$conn = db_connect();
$now = time();
$sql = “delete from stories where id = $story”;
$result = mysql_query($sql, $conn);
header(“Location: $HTTP_REFERER”);
?>
Searching
Clicking the keywords link on the stories list brings up a new form for entering keywords
against the story. There is no limit to the number of keywords that can be entered, and each
keyword is given a weight value, with a higher value indicating that it is more relevant.
Figure 26.7 shows the screen used to set keywords against a particular story.
The script keywords.php is fairly straightforward, so we wont look at it in any detail. It is
included on the CD-ROM.
This script triggers the keyword_add.php and keyword_delete.php scripts. These scripts are
also straightforward, and are therefore not included here.
The script keyword_add.php uses the following query to add new keywords to the database:
insert into keywords (story, keyword, weight)
values ($story, ‘$keyword’, $weight)
In a similar vein, keyword_delete.php uses the following query to remove a keyword:
delete from keywords where story = $story and keyword = ‘$keyword’
What is interesting is the way in which the weight values are used to calculate a percentage
relevance figure when searching.
Building a Content Management System
C
HAPTER 26
26
CONTENT
MANAGEMENT
SYSTEMS
611
32 7842 ch26 3/6/01 3:36 PM Page 611