php - Removing a specific row result obtained through mysql_query? -
i have code rows out of mysql database:
<?php $result = mysql_query("select * `photos` `photo_category` = 1 , `photo_active` = 1"); while($row = mysql_fetch_array($result)) {; ?> <img src="<?php echo $row['thumb_path'] ?>"><br> creatie datum: <?php echo $row['photo_date'] ?><br> <a href="">delete picture</a> <?php }; ?>
i delete image delete button on. have no thought how should start or how can accomplish this. help welcome!
like others have stated, check out pdo or mysqli interface between database. question. need issue mysql delete command. in order work, mysql user needs have delete privileges on table deleting row from. using illustration above, sql this:
<html> <img src="<?php echo $row['thumb_path'] ?>"><br> creatie datum: <?php echo $row['photo_date']; ?><br> <form name="photo_<?php echo $row['photo_id']; ?>_delete" action="dodelete.php" method="post"> <input type="hidden" name="photo_id" value="<?php echo $row['photo_id']; ?>"> <input class="delete_button" type="submit" name="submit" value="delete"> </form> </html> <?php //dodelete.php if ($_post['submit'] == 'delete') { $photo_id = $_post['photo_id']; $sql = "delete photos photo_id = " . $photo_id . " limit 1"; if (mysql_query($sql)) { //photo deleted. } else { //handle errors. } } ?>
in order work, you're going need add together primary key photos table.
php mysql
No comments:
Post a Comment