function get_orphan_chapters($id) { // ******* Order by is supposedly better done with php sort, not mysql $story = get_story_by_id($id); global $connection; // SELECT DISTINCT removes duplicates from query $query = "SELECT DISTINCT chapters.content, chapters.id, chapters.level \n\tFROM chapters LEFT JOIN story_chapter ON chapters.id = story_chapter.chapter_id \n\tLEFT JOIN stories\n\tON story_chapter.story_id = stories.id \n\tLEFT JOIN chapter_option ON chapters.id = chapter_option.chapter_id\n\tLEFT JOIN options ON chapter_option.option_id = options.id\n\tWHERE stories.id={$id}\n\tAND\n\toptions.child_chapter = 0\n\tAND\n\tchapters.endpoint = 0\n\tORDER BY chapters.level ASC"; $result_set = mysql_query($query, $connection); confirm_query($result_set); return $result_set; }
} } } else { // Form has not been submitted, so set form variable(s) to empty strings. // That is, the user will be seeing this page for first time, so we show them the empty form $options = array(); // Nothing to set... } include "includes/header.php"; if (!empty($_GET['story_id'])) { $story = get_story_by_id($_GET['story_id']); } else { if (!empty($_GET['parent_id'])) { $story = get_story_by_chapter($_GET['parent_id']); } else { $story = get_story_by_id($_SESSION['story_id']); } } $first_chapter; if ($variables["parent_option_id"] == 0) { $first_chapter = true; $message = "Your story has been saved! Get started..."; } else { $first_chapter = false; } ?> <!-- TITLE --> <h2 class="page-title alt"> Create chapter for<span> <?php print $story['title']; ?>