gudfry Posted July 17, 2008 Share Posted July 17, 2008 hi, I want to create a query with a confirmation yes or no in php to delete a selected file on my database, i ahve a piece of code but it doesnt work, any idea ?? $id=$_REQUEST['id']; if (isset($id=$_REQUEST['id'])) { // $msg box = ok, delete selected file; } else { // $msg box = no ; return to index; } thanks in advance; Link to comment https://forums.phpfreaks.com/topic/115177-delete-file-on-databases-need-help/ Share on other sites More sharing options...
mmarif4u Posted July 17, 2008 Share Posted July 17, 2008 Something like: $id=$_REQUEST['id']; if (isset($id)) { // $msg box = ok, delete selected file; } else { // $msg box = no ; return to index; } If want to delete from folder can use unlink php function and if want to delete from mysql,use query delete. $sql="delete from table where id='$id'"; Link to comment https://forums.phpfreaks.com/topic/115177-delete-file-on-databases-need-help/#findComment-592261 Share on other sites More sharing options...
gudfry Posted July 17, 2008 Author Share Posted July 17, 2008 hi I found this code while searching an whe i run it i noticed that it well deleted selected content in the database which assignd by id. but the some part of line in this code is not working, when i try to read the whole code it looks like a onfirmation box yes or no. like if i clik ok the content would be deleted if i click no it should no be deleted. but i have a problem with this even the msg box doex not displayed. Any i dea with this?? echo "<script language=\"Javascript\">\n"; mysql_connect("localhost", "mindanao_hotels", "hotels")or die("cannot connect"); mysql_select_db("mindanao_hotels")or die("cannot select DB"); $id=$_REQUEST['id']; echo "var x = confirm ('Do you want to delete?');\n"; echo "if (x == true) { \n"; echo $sql= "DELETE FROM hotelinfo WHERE id = '$id'"; mysql_query($sql) or die("Oops2..."); echo "alert ('something deleted');\n }"; echo "else {\n"; echo "alert ('Nothing deleted');\n }"; echo "</script>"; ?> Link to comment https://forums.phpfreaks.com/topic/115177-delete-file-on-databases-need-help/#findComment-592337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.