Ejemplo n.º 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);
}
<?php

/* This script deletes a comic chapter or page.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
/*****
 * Chapter
 */
if ($_GET['delete-chapter']) {
    $id = strfunc_get_id($_GET['delete-chapter']);
    if ($id) {
        delete_chapter($id, $db);
    }
}
/*****
 * Page
 */
if ($_GET['delete-page']) {
    $id = strfunc_get_id($_GET['delete-page']);
    if ($id) {
        delete_comic_page($id, $db);
    }
}
Ejemplo n.º 3
0
<?php

require_once "helper-functions/connection.php";
require_once "helper-functions/functions.php";
require_once "helper-functions/delete_functions.php";
if (intval($_GET['chapter']) == 0) {
    redirect_to("all_stories.php");
}
// get the id of the chapter
$id = mysql_prep($_GET['chapter']);
// if the id corresponds to an actual chapter, start process
if ($chapter = get_chapter_by_id($id)) {
    // Capture the parent chapter before deletion (otherwise, you won't be able to find it)
    $parent = get_parent_of_chapter($chapter['id']);
    $errors = array();
    // Call function in functions.php
    delete_chapter($id);
    // If successful, redirect to the parent chapter
    redirect_to("read_chapter.php?chapter={$parent['chapter_id']}&deleted=1");
}
?>

<?php 
mysql_close($connection);