예제 #1
0
function delete_story($id)
{
    global $connection;
    // $id is the id of a story
    // First, get all chapters that are in this story
    $chapter_set = get_chapters_in_story($id);
    // Loop through chapters and delete them and all associated references
    while ($chapter_id = mysql_fetch_array($chapter_set)) {
        delete_chapter($chapter_id[0]);
    }
    // Finally, delete the story
    $query = "DELETE FROM stories WHERE id = {$id} LIMIT 1";
    $result_set = mysql_query($query, $connection);
    confirm_query($result_set);
}
// Select existing chapter.php. Lists all chapters in a story with links to use as an option.
// The idea is to help a writer reuse chapters rather than create new ones.
// *****************************************************************************
?>

<h2 class="page-title">Use Existing</h2>
<div id="chapter-block">
  <p class="description">
		Select one of the existing chapters instead of creating a new one. The effect will be to have loops within your story, where a reader might end up back in a chapter they've already read... 
  </p>
</div>
<?php 
if (isset($_GET['chapter']) && is_numeric($_GET['chapter'])) {
    $chapterID = intval($_GET['chapter']);
    $story = get_story_by_chapter($chapterID);
    $chapter_set = get_chapters_in_story($story['id']);
}
if (isset($_GET['option']) && is_numeric($_GET['option'])) {
    $option_id = intval($_GET['option']);
}
global $connection;
$pager = new Pager($connection, "all-chapters");
$result = $pager->getResult();
//  Use $story_set data
//	Loop through data to create list of stories
if (isset($chapter_set)) {
    while ($chapter = mysql_fetch_array($chapter_set)) {
        ?>
			<div class="body">
			<?php 
        print $chapter['content'];