put a check box inside of a table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • pipesportugal
    Second Lieutenant

    • Jul 2007
    • 130

    put a check box inside of a table

    Hello dear colleagues from the VH forum,

    Can someone make me the big favour of explaining how we can put a check box inside of a table ?

    I mean this when You are listing (for example) Your customers in the screen after a "select" sentence.
    I would like to give the opportunity to the user to check the box on the chosen customer/line, in which he wants to perform an operation, which could be chosen from a series of buttons at the end of the listing.

    Hope it's clear,

    Thanks for all the answers,
    pipesportugal
  • Watdaflip
    Major General

    • Sep 2005
    • 2116

    #2
    Re: put a check box inside of a table

    So to make sure I get you right... you want list all of your customers in a table, each customer on a row, and it just lists down the page. On each row you want to have a check box next to each customer name, and finally at the end of the list have the buttons to perform whatever action on all customers who checkbox was checked?

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment

    • pipesportugal
      Second Lieutenant

      • Jul 2007
      • 130

      #3
      Re: put a check box inside of a table

      Yes, that's it Watdaflip,

      Like in the phpmyadmin after You check the box You have then below some buttons where You can decide to edit, delete, etc make, an operation to the chosen line.

      On a table, to make a link is very easy because You add the customer number to the link, such as: edit_client.php?client=$client_number, right?

      But for a checked box how do I know the customer number ?

      Thanks for replying,
      pipesportugal

      Comment

      • Watdaflip
        Major General

        • Sep 2005
        • 2116

        #4
        Re: put a check box inside of a table

        Basically you just set the name of each check box to be... for instance "customer[]", which makes it into an array. Set the value of each check box to be the row number in the database table.

        Once submitted you just have to loop through the posted variable as an array, ie

        PHP Code:
        $count count($_POST['customer']);
        for(
        $i=0$i $count$i++)
        {
        // do whatever to each customer id
        // each is will be $_POST['customer'][$i]

        Of course you will want to verify all posted data is safe.

        If you need any more explanation I will try to go more in depth or write you an example

        Register/Login Script
        Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

        Comment

        • pipesportugal
          Second Lieutenant

          • Jul 2007
          • 130

          #5
          Re: put a check box inside of a table

          Hi Watdaflip,

          I understand Your code.
          That's the code for retrieving the customer number on the "other side / action program" (after the button submiting).

          This method will force me to "create" a form, put my listing (everything) inside this form and add a submit button, so that I can pass the array customer[] with the $_POST method to the "action program".

          I also checked the html source code at the phpmyadmin page and based on what I saw, this is what it must be done in the table:

          $line = "<td><center><input type=checkbox name=customer[] value=$customer_number id=checkbox1 /></td>";
          $line .= "...............

          This works. I've tested it.

          But..... I'd like to use several buttons and javascript and the $_GET method in the browser command to execute the required tasks, but I imagine that it must not be possible.

          In case You have any idea I would very much appreciate the help.

          Also from my side I will keep my search to evaluate the possibility
          of doing it without being forced to "construct" the form.

          Thanks,
          pipesportugal

          Comment

          • pipesportugal
            Second Lieutenant

            • Jul 2007
            • 130

            #6
            Re: put a check box inside of a table

            Hi,

            In fact for the purpose I wanted is better to use a RadioButton, because this way, only one customer will be chosen.

            the philosofy would be the same...

            ....
            $line .= "<td><center><input type=radio id=RadioButton1 name=customer[] value=$customer_number</td>";
            ....

            But I would still need to put everything inside of a form and add a submit button and so on.....

            Any ideas ? thanks all,
            pipesportugal

            Comment

            • navaldesign
              General & Forum Moderator

              • Oct 2005
              • 12080

              #7
              Re: put a check box inside of a table

              You don't need to construct the main form body. Add the code to the $line variable using a loop, add at the end the ***essary buttons and you are done.
              Make sure to add the openin <form and closing /form> tags

              I use the same method (with delete icon and a text box for quantity updting) for my shopping cart.

              Unless i misread something..
              Navaldesign
              Logger Lite: Low Cost, Customizable, multifeatured Login script
              Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
              DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
              Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

              Comment

              • Watdaflip
                Major General

                • Sep 2005
                • 2116

                #8
                Re: put a check box inside of a table

                What are you trying to do, this will help so we know what the problem you are running into.

                Register/Login Script
                Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

                Comment

                • pipesportugal
                  Second Lieutenant

                  • Jul 2007
                  • 130

                  #9
                  Re: put a check box inside of a table

                  Hi, You make quite a great team! Congrats,

                  I've been able to do it with the form and /form tags and inserted the code manually for the POST method and it works fine.

                  Watdaflip, what You said at Your first post to my thread made me think that You had got it right, at the first time.

                  Thank You guys !

                  Pipesportugal

                  Comment

                  Working...
                  X