对于具有单选按钮和复选框组合的调查应用程序。如何使用PHP将选定的值插入到使用php的mysql数据库? 这是从db:
获取问题的查询while($row2 = $result2->fetch_assoc())
{
if($row2["subtype"] =="radio")
{
echo "<input id = \"radio\" class='radio_input' type=\"radio\" name=answergroup[".$row["PK_QUESTION_ID"].
"] value=".$row2["opt_id"].">".$row2["opt_text"]."</input>";
else if($row2["subtype"] =="checkbox")
{
echo "<input id = \"checkbox\" class='radio_input' type=\"checkbox\" name=answergroup[".$row["PK_QUESTION_ID"].
"] value=".$row2["opt_id"].">".$row2["opt_text"]."</input>";
}
}
我尝试使用$ _POST [&#39; answergroup&#39;]来获取所选的选项,但是在复选框的情况下,即使有多个选项,也只会获取一个选项。
答案 0 :(得分:1)
当您处理具有相同名称的多个Sub Mismatch()
Dim sht As Worksheet
Dim i As Integer
Dim j As Integer
Dim last As Integer
''OPEN FILE
sFileName = Application.GetOpenFilename("Excel Files (*.xls;*.xlsx;*.xlsm;*.xla;*.xlam),*.xls;*.xlsx;*.xlsm;*.xla;*.xlam, All Files (*.*), *.*", 1, "Select Authorization Issued Report File")
If sFileName = "False" Then Exit Sub
Application.DisplayAlerts = False
Set auth = Workbooks.Open(sFileName, UpdateLinks:=xlUpdateLinksNever)
'unfilter
ActiveSheet.Range("$A$1:$BH$19322").AutoFilter Field:=15
Columns("AZ:AZ").EntireColumn.Select
Selection.NumberFormat = "0"
'add new sheet
Set sht = Sheets.Add
sht.Name = "Mismatch"
Sheets("Mismatch").Select
With ActiveWorkbook.Sheets("Mismatch").Tab
.Color = 255
.TintAndShade = 0
End With
''find Mismatch
Sheets("Authorizations Issued").Select
Range("A1:BI1").Copy
Sheets("Mismatch").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Authorizations Issued").Select
last = ActiveSheet.UsedRange.Rows.Count
j = 2
For i = 2 To last
Sheets("Authorizations Issued").Select
If Range("$K$" & i).Value <> Range("$AZ$" & i).Value Then
Range("$A$" & i & ":$BH$" & i).Copy
Sheets("Mismatch").Select
Range("$A$" & j).Select
ActiveSheet.Paste
j = j + 1
Else: j = j
End If
Next i
Sheets("Mismatch").Select
ActiveSheet.UsedRange.Select
Selection.EntireColumn.EntireColumn.AutoFit
''vlookup SAP cust name
Columns("BA:BA").EntireColumn.Select
Selection.Insert Shift:=xlToRight
Range("BA2").Value = "SAP Cust Name"
mismatchLast = ActiveSheet.UsedRange.Rows.Count
Range("BA3").Select
s2FileName = Application.GetOpenFilename("Excel Files (*.xls;*.xlsx;*.xlsm;*.xla;*.xlam),*.xls;*.xlsx;*.xlsm;*.xla;*.xlam, All Files (*.*), *.*", 1, "Select second file")
If s2FileName = "False" Then Exit Sub
Application.DisplayAlerts = False
Set f2 = Workbooks.Open(s2FileName, UpdateLinks:=xlUpdateLinksNever)
cmfLast = ActiveSheet.UsedRange.Rows.Count
auth.Activate
For i = 3 To mismatchLast
Selection.Formula = "=VLOOKUP(AZ" & i & ",'[f2.name]Sheet1'!$A$1:$B$" & cmfLast & ",2,0)"
ActiveCell.Offset(1, 0).Select
Next
End Sub
时,在这种情况下,checkboxes
的名称必须是以下数组:
checkboxes
在表单提交上,您可以获得以下值:
<input type="checkbox" name="options[]" value="1">
此处$options = $_POST['options'];
是一个数组,因此请使用$options
来获取其元素。