dsjmrpym220113739 2013-03-31 23:26
浏览 12

在php中获取HTML复选框的值

I am creating an HTML form and I have a textbox in that. My requirement is that a user can check multiple check boxes, and then I have to get all checked values and then send the values to the database (I want to use PHP).

Here is my code for within the textbox

     $Intensive=$_POST['Intensive'];
  $Intensive_count=count($Intensive);
  $i=0;
  //$count=0;
    //$index;
  $max=0;
  //$index;
   While($i < $Intensive_count)
   {
    if($Intensive[$i]=="High frequency ventilation" )
   {
   $Intensive_score=4; 
  }
     elseif($Intensive[$i]=="Mechanical ventilation with muscle relaxation")
  {
   $Intensive_score=4;
  }
  elseif($Intensive[$i]=="Mechanical ventilation")
  {
   $Intensive_score=3;
  }
  elseif($Intensive[$i]=="CPAP")
  {
   $Intensive_score=2;
  }
  elseif($Intensive[$i]=="supplemental oxygen")
  {
   $Intensive_score=1;
  }

 if($Intensive_score>$max)
  {
   $max=$Intensive_score;
   $index=$i;
 }
  $i++;
 }

Now with the above code I am able to echo the value ,but the record is not going to the database.

$sql1="insert into Form2 values('$Medical_Record_Id','$sub1','$Question1','4','$Intensive[$index]','$max')";

 mysql_query($sql1);

Could anybody tell me how to go about it.

Thanks ..:)

  • 写回答

2条回答 默认 最新

  • dongwei3712 2013-03-31 23:35
    关注

    Assuming you are using POST as the method for sending the form those checkboxes are in, you can get the values array with $_POST['Intensive'].

    评论

报告相同问题?