Delete all checked boxes problem !

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Delete all checked boxes problem !

    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

    Click image for larger version

Name:	untitled.PNG
Views:	1
Size:	4.1 KB
ID:	112432

    PHP Code:
    <?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:

    HTML Code:
    <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////
    Last edited by just_m3.; 10.09.11, 20:24.
    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!

    #2
    maybe this helps. I'm from mobile now so i can't type the code but you get the idea

    Comment


      #3
      yeah already got it but i think it definitely use register_globals on

      Done it :D


      PHP Code:
      <?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 .. .
      Last edited by just_m3.; 10.09.11, 20:58.
      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!

      Comment

      Working...
      X