我面临的情况就是这样:
我从数据库中读取数据并将其转储到网页的表格中。然后,根据列的值,显示或不显示下拉列表。并将下拉列表中的值写回数据库。
我使用...提交,但$ _GET没有关于下拉列表的值。
我列出了这里设置的整个代码。
非常感谢任何帮助!
$GCdataSQL = "select * from table_name";
$GCdata = new Query($GCdataSQL);
$table = "<form method='GET'><table class='datatable table table-condensed ' id='query-data'><thead><tr>";
$ColName = array('col1','col2','col3','col4', 'col5', 'col6', 'col7', 'col8');
foreach ($ColName as $Name){
$table .= "<th>$Name</th>";
}
$table .= "</tr></thead><tbody>";
while ($GCdataRow = $GCdata->fetchRow()){
$emplid = $GCdataRow['emplid'];
$term = $GCdataRow['term'];
$handled = $GCdataRow['handled'];
if ($GCdataRow['code'] == 'UNKNOW' || $GCdataRow['code'] == 'Not Repeated'){$GCdataRow['code']= '';}
if ($GCdataRow['local_action'] !== $GCdataRow['new_action']){
$table .= "<tr bgcolor= 'LightPink'>";
}
else {
$table .= "<tr>";
}
foreach($GCdataRow as $key=>$value){
if ($key == 'emplid'){
$table .="<td><a href='link' target = '_blank'>$value</a></td>";
}
else if ($key == 'new_action'){
$table .="<td><a href='link' target = '_blank'>$value</a></td>";
}
else if ($key == 'handled' && $handled == 'Not Reviewed'){
$table .="<td><select name = 'handlecode'><option value = 'Not Reviewed'>Not Reviewed</option><option value = 'Handled by Script'>Handled by Script</option><option value = 'Handled Manually'>Handled Manually</option><option value = 'Leave It'>Leave It</option></select></td>";
}
else {
$table .= "<td>".htmlentities($value)."</td>";
}
}
$table .= "</tr>";
$loopcount++;
}
if(isset($table)) {$table .= "</tbody></table>";}
echo $table;
echo "<button type='submit' class = 'btn btn-primary' style = 'position: absolute; left:50%;' >Submit</button></form>";
答案 0 :(得分:1)
最后我将表单方法更改为POST,一切都很好!现在值在$ _POST中,我可以使用它们插入数据库!
谢谢!