Delete all checked boxes problem !

Started on the old forum in September 2011 · view the original in the archive · old links redirect here

2 replies · 390 views · started 15 years ago · 1 min read

2 participants
just_m3. Developer · 199 posts #1

Hy , let's get straight to the problem here , i need a loop code to process and delete all submited chekbox'es ids / by submit form

queryes preview list

<?php
include'include/functie.php';

$query=mysql_query("SELECT * FROM table_postblog WHERE user='username' ");
$num_rows = mysql_num_rows($query);

if ($_GET['cmd']=="delete"){
echo'<form name="form1" method="post" action="blog.php?cmd=delchecked">';
// loop through the query's and  list  
while($rows=mysql_fetch_array($query)){
echo'<input name="checkbox"  type="checkbox" value="'.$rows['idul'].'">
'.$rows['postname'].'<br/>
'.$rows['date'].'<br/>';

}

echo'<input name="delete" type="submit" value="delete"></form><br/>';
//echo "".$num_rows." posts";
}

if($_GET['cmd']=="delchecked"){

// need the loop code to delete all submited id's ??? 
the_loop_here(){

$result = mysql_query("DELETE FROM table_postblog WHERE idul='".$removeid."'");
if ($result){echo"succesfully deleted <br/>";}
else if (!$result){echo"sorry can't be deleted"; exit;}
else{echo"system error";}

}
}

?>

PLEASE HELP ME OUT ! i already tried some google found' examples non worked !

if you got any working example that doesn't use register_globals=on and can delete multiple "rows" from database, please post !!

tnx 😊

Added after 3 minutes:

<form name="form1" method="post" action="blog.php?cmd=delchecked"><input name="checkbox" id="checkbox"  type="checkbox" value="11">
Real football 2012<br/>
04/09/2011<br/><input name="checkbox" id="checkbox"  type="checkbox" value="12">
De ce sa folosesti uppy.me?<br/>
06/09/2011<br/><input name="checkbox" id="checkbox"  type="checkbox" value="15">
Admob Suge <br/>
06/09/2011<br/><input name="checkbox" id="checkbox"  type="checkbox" value="17">
Nimic #7<br/>
06/09/2011<br/><input name="checkbox" id="checkbox"  type="checkbox" value="18">
Hostgator<br/>
06/09/2011<br/><input name="checkbox" id="checkbox"  type="checkbox" value="20">
<input name="delete" type="submit" id="delete" value="delete"></form>

i know that the name="checkbox" should be like name="checkbox[]" but i don't know how the hell should be codded////

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

Attachments: untitled.PNG
just_m3. Developer · 199 posts #3

yeah already got it but i think it definitely use register_globals on 😒

Done it 😀

<?php
include'include/functie.php';
$query=mysql_query("SELECT * FROM iMobile_shot_postblog WHERE utilizator='username' ");
$num_rows = mysql_num_rows($query);

if ($_GET['cmd']=="delete"){
echo'<form name="form1" method="post" action="blog.php">';

while($rows=mysql_fetch_array($query)){
echo'<input type="checkbox" name="checkbox[]"  value="'.$rows['idul'].'">
'.$rows['titlupost'].'<br/>'.$rows['data'].'<br/>';}
echo'<input name="delete" type="submit" value="delete"></form><br/>';
//echo "".$num_rows." posts";
}

if(isset($_POST['delete'])){
foreach($_POST['checkbox'] as $id) 
{ $result = mysql_query("DELETE FROM iMobile_shot_postblog WHERE idul='".$id."'");
if ($result){echo"succesfully deleted <br/>";}
else if (!$result){echo"sorry can't be deleted"; exit;}
else{echo"system error";}}}

?>

tnx for the help bro' realy apreciate it .. .

i think someone else was searching for this to ... tnx again .. .

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close