Create variable for deletion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • burgensteen
    New Member
    • Sep 2006
    • 7

    Create variable for deletion

    Hi,
    I have created a couple of drop down option menus with the from and to values of my login sessions and am after creating a delete variable for these records
    i.e
    1,2,3,4,5,6,7,8 ,9
    the user may choose from the drop downs to delete for example 4 to 8.

    But I cannot work out the function sum to put in my PHP delete command?????

    Any ideas most welcome.
    Thanks
    Jon
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    hai friend I am not clear how to delete the drop down box r u mentioned dropdownbox are list box?

    Comment

    • burgensteen
      New Member
      • Sep 2006
      • 7

      #3
      Hi,
      For example:
      Drop down 1: 1,2,3,4,5,6,7,8 ,9
      Drop down 2: 1,2,3,4,5,6,7,8 ,9


      The client would choose to delete the 'from' and 'to' value (inclusive)i.e:
      From 2 (taken from dropdown 1) to 5 (taken from drop down 2).
      Then the sum would be done: delete 2,3,4,5 from the session list in my database.
      I cant seem to work out the function needed for this sum

      Thanks for responding

      Jon

      Comment

      • tbb9216
        New Member
        • Sep 2006
        • 16

        #4
        [php]
        $d1 = 'dropdown 1';
        // example: d1 = 2
        $d2 = 'dropdown 2';
        // example: d2 = 5

        for ( $i = $d1; $i <= $d2; $i++ ) { // 2 <= $i <= 5 in other words, from 2 to 5
        $que = "DELETE
        FROM table
        WHERE id = '$i'";
        $res = mysql_query($qu e);
        }
        [/php]

        this will cycle through the selected number range and delete rows accordingly from the db

        good luck,
        -tim

        Comment

        • burgensteen
          New Member
          • Sep 2006
          • 7

          #5
          Thanks alot.
          I shall give it a try

          Comment

          Working...