0
我已經創建了一個數據庫驅動的PHP表單,並且動態地填充問題並取得了巨大成功。不幸的是,有一個新問題,我似乎無法得到我的頭...PHP中的動態RADIO選項子組 - 表包裝問題
我遇到的問題是獲得「藍色表標題標題」以正確顯示。當我呈現形式,它看起來像這樣...
,但我希望它看起來像這樣:
這是一個簡化版本,我的代碼:
// Connect to the database
-- insert connection code here --
// SQL Query to get question
-- insert query code here --
//initialize form
echo '<form name="surveyForm" method="post" action="submit.php">' . "\n";
//begin display of form questions
while($row=mssql_fetch_array($result)){
//display question
echo $row['question'];
//determine question sub-form elements
if($row['questionType'] == 4) { //this is for a radio-button group
echo ('<table>
<tr>
<th> </td>
<th>1</th>
<th>2</th>
</tr>');
}
//sub-query for question form elements
-- insert sub-query form element code here --
while($subrow=mssql_fetch_array($subresult)){
//display the question form element
$formType = $subrow['formType'];
$formNameAttribute = $subrow['formName'];
$formClassAttribute = $subrow['formClass'];
-- etc. ---
echo $htmlBuild = '<input type="$formType" name="$formNameAttribute" class="$formClassAttribute"';
-- etc. ---
//If RADIO-BUTTON GROUP
-- insert radio button display code here --
}
if($row['questionType'] == 4) {
echo '</tr></table>';
}
}
//close out form
echo ('<input type="submit" value="Submit" class="submit" name="submitBtn" />
<input name="Reset" type="reset" value="Reset Form" />');
但正如你所看到的,如果我嘗試添加表頭,我不知道如何使該子組單選按鈕表頭不再重複。
謝謝!