Sending Check Box Value to Database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mahbub Hasan
    New Member
    • Nov 2006
    • 2

    Sending Check Box Value to Database

    There r 3 checkbox . .. first check box value = 2 , second check box value = 4 , third check box value = 6 . now if i check 1st one it will send 2 to the database field, if check the first and second it will send the value ( 2*4) =8 to the database, if check the first second and third it will send the value ( 2*4*6) =48 to the database, ...

    Now how will i solve the problem
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Now what is the problem? Please elaborate because I don't understand what you are asking.

    As I understand you want the values of all checkboxes that are checked to be multiplied with each other and the result must be stored in the database??

    Ronald :cool:

    Comment

    • swandi
      New Member
      • Nov 2006
      • 13

      #3
      Please try this code :
      [PHP]
      if(isset($_POST['first_check']))
      {
      if(isset($_POST['second_check']))
      {
      if(isset($_POST['third_check']))
      {
      $value = $_POST['first_check'] * $_POST['second_check'] * $_POST['third_check'];
      }
      else
      {
      $value = $_POST['first_check'] * $_POST['second_check'];
      }
      }
      else
      {
      $value = $_POST['first_check'] ;
      }

      insert_to_db($v alue);
      }

      [/PHP]

      Comment

      • theRamones
        New Member
        • Nov 2006
        • 13

        #4
        [php]
        $first_check = $_POST['first_check'] ? $_POST['first_check'] : 1;
        $second_check = $_POST['second_check'] ? $_POST['second_check'] : 1;
        $third_check = $_POST['third_check'] ? $_POST['third_check'] : 1;

        //total
        $value = $first_check * $second_check * $third_check;
        [/php]

        Comment

        • Mahbub Hasan
          New Member
          • Nov 2006
          • 2

          #5
          Thank u for ur reply.. yes u' ve understand my problem . Yes I want to send the checkbox value to the database by multiplying .....

          Comment

          Working...