php - How do i make delete button work? -
i trying make delete button doesn't work.
$interogare = "select * comments join users on users.user_id = comments.user_id movie_id='$movie_id' order date_posted desc"; $result = mysqli_query($dbc, $interogare) or die(mysqli_error($dbc)); while($rand = mysqli_fetch_assoc($result)) { echo '<a href="film.php?com='.$rand['comment_id'].'">delete</a>'; if(isset($_get['com'])) { $haidi = mysqli_real_escape_string($dbc,$_get['com']); $sql_del = "delete comments comment_id = '$haidi'"; mysqli_query($dbc,$sql_del); header('location: film.php?id='.$_get['id'].''); exit(); } } when click delete link takes me
film.php?com='.$rand['comment_id'].'
page nothing happens,it should delete comment , take me page comment was.can please me figure out ?
does work?
<?php $query = " select * comments join users on users.user_id = comments.user_id movie_id=" . $movie_id . " order date_posted desc"; $result = mysqli_query($dbc, $query) or die(mysqli_error($dbc)); if (isset($_get)) { $getdata = $_get; } while ($rand = mysqli_fetch_assoc($result)) { echo '<a href="film.php?com=' . $rand['comment_id'] . '">delete</a>'; if (isset($getdata) && $getdata['com']) { $id = mysqli_real_escape_string($dbc, $getdata['com']); $query = " delete comments comment_id=" . $id; $result = mysqli_query($dbc, $query); if($result) { header('location: film.php?id=' . $id . ''); } exit(); } } i rather grab post once, , make sure passing same object around, set var. then, didnt way ids being set in query, because wasnt easy see. got down way creating header, , looked passing id data, instead of id extracted , set varibale, see above..., or intention use $_get['id'] instead?
also, might need pass data link in mysqli_real_escape_string() method
Comments
Post a Comment