fuyuchi Posted January 20, 2010 Share Posted January 20, 2010 Hii, I am having some trouble trying to create a Delete Record webpage. What I want is a sort of button created which when being clicked on will hides the selected record from the user. That means the record the user wanted to "deleted" will be hidden from them but still shows up in the database. The only workable codes I have are the basic delete function of php and it deletes the records from the database which I do not wish for it to happen. I will appreciate any help. Sorry if my english sucks. (^^|||) Search for a module to delete. <html> <head> <title>Delete Module</title> </head> <body> <form action="testDelete.php" method="post"> <table> <tbody> <tr> <td>Enter Module Code:</td> <td><input type="text" name="delete" /></td> </tr> <tr> <td> <p><input type="submit" value="Delete Modules" /></p> </td> </body> </html> The deleted page. <head> <SCRIPT LANGUAGE="JavaScript"> function goToURL1() { window.location = "index.php"; } </SCRIPT> </head> <?php $mysqluser = "user1"; ///change to your userid $mysqlpass = "12345"; /// change to your password $mysqldb = "ModuleDatabase"; /// change to your database name $delete= $_POST['delete']; mysql_connect(localhost,$mysqluser,$mysqlpass); @mysql_select_db($mysqldb) or die( "Unable to select database"); mysql_query("DELETE FROM modules WHERE code='$delete'"); mysql_close(); echo"Module deleted"; echo"<FORM><INPUT TYPE=\"button\" VALUE=\"Back\" onClick=\"history.go(-1);return true;\"> </FORM>"; ?> <input type=button value=" HOME " onClick="goToURL1()"> Link to comment https://forums.phpfreaks.com/topic/189125-deletehide-function/ Share on other sites More sharing options...
p2grace Posted January 20, 2010 Share Posted January 20, 2010 Just create a field in the database called "deleted". Then change your delete query to an update query to mark deleted as "1" instead of the default "0". Then update your query to display results to only return those where deleted is equal to 0. Make sense? Link to comment https://forums.phpfreaks.com/topic/189125-deletehide-function/#findComment-998472 Share on other sites More sharing options...
fuyuchi Posted January 20, 2010 Author Share Posted January 20, 2010 It worked! Thank you! Link to comment https://forums.phpfreaks.com/topic/189125-deletehide-function/#findComment-998534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.