function delete_ranking($dbh, $rank_id)
{
    foreach ($rank_id as $id) {
        $sql = 'SELECT movie_id FROM movie WHERE rank_id = ?';
        $stmt = $dbh->prepare($sql);
        $data[] = $id;
        $stmt->execute($data);
        $data = array();
        while (true) {
            $rec = $stmt->fetch(PDO::FETCH_ASSOC);
            if ($rec == false) {
                break;
            }
            delete_movies($dbh, $rec['movie_id']);
        }
        delete_button($dbh, $id);
        $sql = 'DELETE FROM ranking WHERE rank_id = ?';
        $stmt = $dbh->prepare($sql);
        $data[] = $id;
        $stmt->execute($data);
        $data = array();
    }
}
Beispiel #2
0
<?php

session_start();
session_regenerate_id(true);
if (isset($_SESSION['login']) == false) {
    header('Location:http://csan5lg-ago-app000.c4sa.net/');
    //非ログインはトップへ飛ばす
}
require_once "./common.php";
require_once "./delete_contents.php";
$post = sanitize($_POST);
//配列がajaxで渡せなかったので、','で区切ったデータ(文字列)を受け取って配列化する
$content_id = explode(',', $post['content_id']);
try {
    $dbh = connectDB();
    delete_movies($dbh, $content_id);
    $dbh = null;
} catch (Exception $e) {
    echo 'ただいま障害により大変ご迷惑おかけしております。';
    echo $e;
    exit;
}