在使用括號表示法之前,我將元素分組在一起,但我必須忽略某些內容。也許另一雙眼睛(或成千上萬)可以發現爲什麼這是回火。HTML分組輸入返回'數組',而不是PHP中的值的數組
foreach ($record as $field => $value) {
if(strpos($value , '~') !== FALSE){ //All drop down lists are separated by ~
$rows_of_dlist .= '<tr>';
$stored_field = explode ("mlljx", $value);
$stored_field [0] = trim ($stored_field [0]); //Title of the list
$stored_field [1] = trim ($stored_field [1]); //Values of the list
$dlist = explode ('~', $stored_field [1]);
foreach ($dlist as $dlist) {
$list_values .= " <td><input type='checkbox' name='selected_option[]'value='$dlist'/> $dlist</td>";
}
$rows_of_dlist .= "<td align = 'center'>$stored_field[0]</td> $list_values</tr>";
<form id="all" name="all" method="POST" action="$page_name?page_view=report" >
<table align="center" width = "100%" border = "2">
<th colspan = "1">Name Of Custom Drop-down List</th>
<th colspan = "10">Drop-list Values</th>
$rows_of_dlist
<tr>
<td align = 'center' colspan='10'>
<input type="submit" value="Make PDF" name = "make_pdf"/>
</td>
</tr>
</table>
</form>
值被公佈後,我考了POST數組:
var_dump($_POST);
exit;
於是說$_POST['selected_option']
是「數組」即使我選擇只有一個框。
什麼是生成的HTML源(提交表單)? – Jocelyn
在name ='selected_option []'和value ='$ dlist'/>之間是否需要空格? –
如果我理解正確的HTML是什麼已經發布。我們使用模板,因此我會在變量中調整表單的形式,並且魔術會發生在後臺。我動態地構建表格。它是一個非常簡單的頁面,這就是爲什麼這使我瘋狂。 不幸的是,空間並沒有解決它,但很好的抓住。 – user1193752