darkfreaks Posted February 13, 2008 Share Posted February 13, 2008 okay i want to make a delete form when the checkbox is checked and you press submit it carries out my delete functions in my delete file, how would i do this??? Quote Link to comment https://forums.phpfreaks.com/topic/90811-form-structure/ Share on other sites More sharing options...
phpSensei Posted February 13, 2008 Share Posted February 13, 2008 Please atleast provide some coding you have done, this seems as if your asking us to do the job for you. Make the form atleast, and then come back asking the question. Also, read on the DELETE command in MYSQL... Quote Link to comment https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465458 Share on other sites More sharing options...
darkfreaks Posted February 13, 2008 Author Share Posted February 13, 2008 ok like ihad tried echo" <td>Delete</td> <form method=post action=delete.php> <td><input type=checkbox name=checkbox[]></td> <td><input type=submit name=Submit></td>"</form>; it shows nice on the form but it does not submit ordo anything. Quote Link to comment https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465467 Share on other sites More sharing options...
cooldude832 Posted February 13, 2008 Share Posted February 13, 2008 best way to do deletes is an array i.e <input type="checkbox" name="deletes['ITEMTODELTEKEY']" value = "1" /> Then on your proecssor page very easily you can do <?php foreach($_POST['deletes'] as $key=>$value){ if($value == "1"){ #Run delete on $key } } ?> That is how i do mysql deletes except I form the WHERE portion of my query from that vs running a hard query here you want to file delete so you run it right in teh foreach loop Quote Link to comment https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465469 Share on other sites More sharing options...
darkfreaks Posted February 13, 2008 Author Share Posted February 13, 2008 right here is the same code in delete.php if($_POST['deletetopic']) { foreach($_POST as $id) { include ('config.php'); mysql_query("DELETE FROM vc_coventopics AND vc_covenmessages WHERE catid='$id'"); echo "Topic deleted"; mysql_close(); }; }; same code i just need to find a way for it to run??? Quote Link to comment https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465472 Share on other sites More sharing options...
cooldude832 Posted February 13, 2008 Share Posted February 13, 2008 use what I had modded so you only use 1 query <?php foreach($_POST['deletes'] as $key=>$value){ if($value == "1"){ $deletes[] = "catid = '".$key."'"; } } $where = implode(" || ",$deletes); $q = "DELETE from `vc_coventopics` AND v`c_covenmessages` where ".$where."; $r = mysql_query($q) or die(mysql_error()."<br /><br />".$q); ?> Only takes 1 query then Quote Link to comment https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465475 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.