Delete Multiple items with checkboxes

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Delete Multiple items with checkboxes

    Hello all,

    I'm sorry for posting this because you probably answered this question a
    million times, but i didn't got my script to run yet.

    I'm using:

    - PHP 4.3.4
    - Mysql
    - Apache 2

    So the problem is that when i try to know witch checkboxes were hit, php
    only returns the last one: imagine that you checked the 10,11,12 and 13;
    it only sees the 13.
    The code is something like this:
    <?
    $sql = "Select id from table";
    $rst = mysql_query($sql);
    while ($row = mysql_fetch_array($rst))
    {
    ?>
    <input type="checkbox" name="check" id="<? echo($row["id"])?>">
    <?
    }
    ?>

    and then, when you want to know witch ones were hited,

    <? echo $check ?>
    And it was supposed to write (10,11,12,13) right?
    The problem is he only echoes the 13.

    Can you help, please?

    Jorge Ferreira


    ##-----------------------------------------------#
    Article posted from PHP Freaks NewsGroup
    [url]http://www.phpfreaks.com/newsgroup[/url]
    Get Addicted: alt.comp.lang.ph
    ##-----------------------------------------------##
    Jorge Ferreira Guest

  2. Similar Questions and Discussions

    1. How to delete items NOT in a list
      I have a table with current movie titles identified by ID number and another table with reviews of those items, also containing the ID number. The...
    2. Checkboxes in grid/delete row not working
      I copied the code for this direclty from http://www.asfusion.com/blog, but for some reason when I go to delete a row in the grid, it merely leaves...
    3. delete mulitple records with checkboxes
      i have a recordset with a looped region and checkboxes each checkbox has the individual record id assigned to it my questions is what SQL command...
    4. can not delete items from desktop (2k server & AD)
      Hello, I deleted some items from desktop. When I log on, items came back. We have 2k server with AD. Profie are on server. Thanks for your...
    5. multiple delete with checkboxes ?
      Hi ! back again... got this problem with multiple delete with checkboxes. when i click the 'Delete user' link i get all users in the db listed...
  3. #2

    Default Re: Delete Multiple items with checkboxes

    *** Jorge Ferreira wrote/escribió (Tue, 01 Jun 2004 05:31:42 -0500):
    > So the problem is that when i try to know witch checkboxes were hit, php
    > only returns the last one
    Two options:

    1) Give each field a different name:

    check1, check2, check3...

    2) Append "[]" to name to force several fields to be treated as an array

    name="check[]"



    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --
    Alvaro G Vicario Guest

  4. #3

    Default Re: Delete Multiple items with checkboxes

    Jorge Ferreira wrote:
    > Hello all,
    >
    > I'm sorry for posting this because you probably answered this question a
    > million times, but i didn't got my script to run yet.
    >
    > I'm using:
    >
    > - PHP 4.3.4
    > - Mysql
    > - Apache 2
    >
    > So the problem is that when i try to know witch checkboxes were hit, php
    > only returns the last one: imagine that you checked the 10,11,12 and 13;
    > it only sees the 13.
    > The code is something like this:
    > <?
    > $sql = "Select id from table";
    > $rst = mysql_query($sql);
    > while ($row = mysql_fetch_array($rst))
    > {
    > ?>
    > <input type="checkbox" name="check" id="<? echo($row["id"])?>">
    > <?
    > }
    > ?>
    >
    > and then, when you want to know witch ones were hited,
    >
    > <? echo $check ?>
    > And it was supposed to write (10,11,12,13) right?
    > The problem is he only echoes the 13.
    >
    > Can you help, please?
    >
    > Jorge Ferreira
    >
    >
    >
    > ##-----------------------------------------------##
    > Article posted from PHP Freaks NewsGroups
    > [url]http://www.phpfreaks.com/newsgroups[/url]
    > Get Addicted: alt.comp.lang.php
    > ##-----------------------------------------------##
    use it like this then php gets an array back after posting

    <input type="checkbox" name="check[]" value="<? echo($row["id"])?>">

    Mart


    Mart Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139