Jump to content

form structure


darkfreaks

Recommended Posts

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

Link to comment
Share on other sites

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???

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.