Jump to content

form structure


darkfreaks

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465467
Share on other sites

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
https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465469
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
https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465472
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
https://forums.phpfreaks.com/topic/90811-form-structure/#findComment-465475
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.