濮阳杆衣贸易有限公司

主頁 > 知識庫 > PHP+mysql實(shí)現(xiàn)的三級聯(lián)動菜單功能示例

PHP+mysql實(shí)現(xiàn)的三級聯(lián)動菜單功能示例

熱門標(biāo)簽:十堰ai電話機(jī)器人效果怎么樣 上海公司外呼系統(tǒng)線路 芒果電銷機(jī)器人 銀川ai電話機(jī)器人 地圖標(biāo)注風(fēng)向標(biāo) 臨沂智能電銷機(jī)器人軟件 電梯外呼線路板維修視頻 浙江外呼電話系統(tǒng)軟件 安陽自動外呼系統(tǒng)價(jià)格是多少

本文實(shí)例講述了PHP+mysql實(shí)現(xiàn)的三級聯(lián)動菜單功能。分享給大家供大家參考,具體如下:

數(shù)據(jù)庫mysql

-- 數(shù)據(jù)庫: `student`
--
-- --------------------------------------------------------
--
-- 表的結(jié)構(gòu) `student`
--
CREATE TABLE `student` (
 `id` int(50) NOT NULL auto_increment,
 `name` varchar(50) collate utf8_unicode_ci NOT NULL,
 `dept` varchar(50) collate utf8_unicode_ci NOT NULL,
 `class` varchar(50) collate utf8_unicode_ci NOT NULL,
 `sex` varchar(50) collate utf8_unicode_ci NOT NULL,
 `dept_id` int(50) NOT NULL,
 `class_id` int(50) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
--
-- 導(dǎo)出表中的數(shù)據(jù) `student`
--
INSERT INTO `student` (`id`, `name`, `dept`, `class`, `sex`, `dept_id`, `class_id`) VALUES
(1, '計(jì)算機(jī)名字', '計(jì)算機(jī)工程系', '計(jì)061', '男', 1, 11),
(2, '教計(jì)名字', '計(jì)算機(jī)工程系', '教技061', '男', 1, 14),
(3, '管理名字', '管理系', '管理061', '女', 2, 21),
(4, '機(jī)械名字', '機(jī)械工程系', '自動化061', '男', 3, 31);

index.php代碼:

?php
$link=mysql_connect("localhost","root","") or die("數(shù)據(jù)庫服務(wù)器連接錯(cuò)誤".mysql_error());
mysql_select_db("student",$link) or die("數(shù)據(jù)庫訪問錯(cuò)誤".mysql_error());
mysql_query("set character set gb2312");
mysql_query("set names gb2312");
?>
html>
 head>
 title>下拉框連動/title>
 /head>
body>
script language="JavaScript">
//二級菜單數(shù)組
var subcat = new Array();
?php
$i=0;
$sql="select * from student";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
 echo "subcat[".$i++."] = new Array('".$arr["dept_id"]."','".$arr["class"]."','".$arr["class_id"]."');\n";
}
?>
//三級菜單數(shù)組
var subcat2 = new Array();
?php
$i=0;
$sql="select * from student";
$query=mysql_query($sql,$link);
while($arr=mysql_fetch_array($query))
{
 echo "subcat2[".$i++."] = new Array('".$arr["class_id"]."','".$arr["class"]."','".$arr["name"]."');\n";
}
?>
function changeselect1(locationid)
{
 document.form1.s2.length = 0;
 document.form1.s2.options[0] = new Option('22請選擇22','');
 for (i=0; isubcat.length; i++)
 {
 if (subcat[i][0] == locationid)
 {
  document.form1.s2.options[document.form1.s2.length] = new Option(subcat[i][1], subcat[i][2]);
 }
 }
}
function changeselect2(locationid)
{
 document.form1.s3.length = 0;
 document.form1.s3.options[0] = new Option('33請選擇33','');
 for (i=0; isubcat2.length; i++)
 {
 if (subcat2[i][0] == locationid)
 {
  document.form1.s3.options[document.form1.s3.length] = new Option(subcat2[i][2], subcat2[i][0]);
 }
 }
}
/script>三級聯(lián)動演示:BR>
form name="form1">
select name="s1" onChange="changeselect1(this.value)">
option>--請選擇--/option>
option value=1>計(jì)算機(jī)工程系/option>
option value=2>管理系/option>
option value=3>機(jī)械工程系/option>
/select>
select name="s2" onChange="changeselect2(this.value)">
 option>--請選擇--/option>
/select>
select name="s3">
 option>--請選擇--/option>
/select>
/form>
/body>
/html>

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php+mysql數(shù)據(jù)庫操作入門教程》、《php+mysqli數(shù)據(jù)庫程序設(shè)計(jì)技巧總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總》

希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。

您可能感興趣的文章:
  • PHP+Mysql+Ajax+JS實(shí)現(xiàn)省市區(qū)三級聯(lián)動
  • jQuery結(jié)合PHP+MySQL實(shí)現(xiàn)二級聯(lián)動下拉列表[實(shí)例]
  • php+mysql實(shí)現(xiàn)的二級聯(lián)動菜單效果詳解
  • jQuery+PHP+MySQL二級聯(lián)動下拉菜單實(shí)例講解
  • 落伍首發(fā) php+mysql 采用ajax技術(shù)的 省 市 地 3級聯(lián)動無刷新菜單 源碼
  • 使用PHP+MySql+Ajax+jQuery實(shí)現(xiàn)省市區(qū)三級聯(lián)動功能示例
  • ThinkPHP使用心得分享-ThinkPHP + Ajax 實(shí)現(xiàn)2級聯(lián)動下拉菜單
  • php 三級聯(lián)動菜單
  • PHP+JS三級菜單聯(lián)動菜單實(shí)現(xiàn)方法
  • thinkPHP實(shí)現(xiàn)的聯(lián)動菜單功能詳解
  • PHP+ajax實(shí)現(xiàn)二級聯(lián)動菜單功能示例

標(biāo)簽:遵義 常州 吐魯番 荊門 寧夏 武威 徐州 遂寧

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PHP+mysql實(shí)現(xiàn)的三級聯(lián)動菜單功能示例》,本文關(guān)鍵詞  PHP+mysql,實(shí)現(xiàn),的,三級,聯(lián)動,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PHP+mysql實(shí)現(xiàn)的三級聯(lián)動菜單功能示例》相關(guān)的同類信息!
  • 本頁收集關(guān)于PHP+mysql實(shí)現(xiàn)的三級聯(lián)動菜單功能示例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    长治县| 睢宁县| 淮安市| 滦南县| 周口市| 承德市| 阜新| 桃园市| 德钦县| 镇康县| 耒阳市| 东山县| 定边县| 建德市| 年辖:市辖区| 越西县| 太和县| 玉林市| 元江| 招远市| 保亭| 绥滨县| 常德市| 从江县| 九寨沟县| 奈曼旗| 宁河县| 建瓯市| 舒城县| 偏关县| 吉木乃县| 青河县| 白玉县| 静海县| 镇远县| 曲阜市| 华池县| 瑞安市| 清水县| 平泉县| 文成县|