//开启了事务,有回滚 mysql_query("BEGIN"); $sql = "delete from booklistname where id={$id}"; $isDelBookList = mysql_query($sql); $sql = "delete from booklist where listcode={$id}"; $isDelListName = mysql_query($sql); if ($isDelBookList && $isDelListName) { mysql_query("COMMIT"); alertMes("删除成功!", "adIndex.php?adminId={$adminId}"); } else { mysql_query("ROLLBACK"); alertMes("删除失败!", "adIndex.php?adminId={$adminId}"); } mysql_query("END"); } elseif ($act == 'edit') { updateListName($id, $arr); } elseif ($act == 'buy') { $booklistId = $arr['booklistId']; $username = $arr['username']; $usernum = $arr['usernum']; $sql = "delete from userlist where usernum = {$usernum}"; mysql_query($sql); print_r($arr); unset($arr['act']); unset($arr['booklistId']); unset($arr['username']); unset($arr['usernum']); foreach ($arr as $key => $val) { mysql_query("BEGIN"); $sql = "select buynum from booklist where id={$key}"; $buyNum = fetchOne($sql);
<?php if (isset($_POST['idUser']) && isset($_POST['id_liste'])) { include_once 'bdd.php'; $bdd = connexionBdd(); if (isset($_POST['listName']) && $_POST['listName'] != '') { $listName = htmlspecialchars(addslashes(trim($_POST['listName']))); updateListName($bdd, $listName, $_POST['idUser'], $_POST['id_liste']); } else { if (isset($_POST['score']) && isset($_POST['temps'])) { updateListScore($bdd, $_POST['score'], $_POST['temps'], $_POST['idUser'], $_POST['id_liste']); } } updateListMots($bdd, $_POST['id_liste'], $_POST['tableMots']); echo json_encode(getListOfList($bdd, $_POST['idUser'])); } ?>