導航:首頁 > 編程語言 > php下拉select

php下拉select

發布時間:2022-12-08 08:06:11

php的select下拉列表取值無法存入資料庫

建議這樣調試,在帖子的最後一個語句($sql="insert into text1 values('$id')";)之後添加下面的三行:
echo "正在執行SQL: $sql<BR> \n";
if (mysql_query($sql)) echo "成功。";
else echo "失敗:".mysql_error();
這樣就會知道資料庫查詢執行是否成功,如果失敗還會顯示失敗的具體原因,這個原因是分析程序非常重要的因素。

❷ php中select下拉選框默認項的動態設置

示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS Selector</title>
<script type="text/javascript">
function createSelect(c){
var _inner = {
"nation" : ['漢族','蒙古族','彝族','侗族','哈薩克族',
'畲族','納西族','仫佬族','仡佬族','怒族','保安族',
'鄂倫春族','回族','壯族','瑤族','傣族','高山族',
'景頗族','羌族','錫伯族','烏孜別克族','裕固族','赫哲族',
'藏族','布依族','白族','黎族','拉祜族','柯爾克孜族','布朗族',
'阿昌族','俄羅斯族','京族','門巴族','維吾爾族','朝鮮族',
'土家族','僳僳族','水族','土族','撒拉族','普米族','鄂溫克族',
'塔塔爾族','珞巴族','苗族','滿族','哈尼族','佤族','東鄉族',
'達斡爾族','毛南族','塔吉克族','德昂族','獨龍族','基諾族'],
"shengxiao" : ['鼠','牛','虎','兔','蛇','蛇','馬','羊','猴','雞','狗','豬'],
"degree" : ['小學','初中','高中','中專','大專','本科','碩士','博士']
}
var _array = c["array"] || _inner[c["type"]];
var _select = document.createElement("select");
for(var i=0; i < _array.length; i++){
_select.options[i] = new Option(_array[i], _array[i]);
_array[i] == c["selected"] && (_select.options[i].selected = true);
}
c["id"] && (_select.id = c["id"]);
c["name"] && (_select.name = c["name"]);
c["onchange"] && (_select.onchange = c["onchange"]);
return _select;
}

function loadRender(){
document.getElementById('field-nation').appendChild(
createSelect({type : "nation", selected : "漢族", name : "nation"})
);
document.getElementById('field-ecation').appendChild(
createSelect({type : "degree", selected : "本科", name : "ecation"})
);
}

</script>
</head>

<body onload="loadRender();">
<div id="field-nation"></div>
<div id="field-ecation"></div>
</body>
</html>

直接把變數傳到:
document.getElementById('field-nation').appendChild(
createSelect({type : "nation", selected : "<?=$nation?>", name : "nation"})
);
document.getElementById('field-ecation').appendChild(
createSelect({type : "degree", selected : "<?=$degree?>", name : "ecation"})
);

閱讀全文

與php下拉select相關的資料

熱點內容
高中畢業當程序員 瀏覽:245
php標簽屬性大全 瀏覽:897
遠程訪問伺服器ip地址 瀏覽:312
程序員吃雞蛋炒菜 瀏覽:173
在哪裡看俄羅斯電視劇app 瀏覽:308
怎麼找資料庫伺服器地址 瀏覽:486
伺服器調試怎麼翻譯 瀏覽:921
php如何處理ajax請求 瀏覽:211
php數組下標存在 瀏覽:707
php獲取ip歸屬地 瀏覽:175
撩女程序員怎麼辦 瀏覽:508
百度伺服器做什麼 瀏覽:193
打開軟體加速伺服器有什麼危害 瀏覽:87
php去除數組下標 瀏覽:794
ipad的app內容哪裡看 瀏覽:284
遇見空間app在哪裡 瀏覽:547
用命令對一個文件內容進行統計 瀏覽:317
華為交換機配置命令縮寫 瀏覽:344
鏈接伺服器出現問題怎麼處理 瀏覽:834
華為手機怎麼打開加密 瀏覽:676