国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Detailed explanation of the secondary linkage menu effect implemented by php mysql, mysql linkage
Home Backend Development PHP Tutorial Detailed explanation of the effect of the secondary linkage menu implemented by php mysql, mysql linkage_PHP tutorial

Detailed explanation of the effect of the secondary linkage menu implemented by php mysql, mysql linkage_PHP tutorial

Jul 12, 2016 am 08:52 AM
html code mysql php

Detailed explanation of the secondary linkage menu effect implemented by php mysql, mysql linkage

This article describes the secondary linkage menu effect implemented by php mysql. Share it with everyone for your reference, the details are as follows:

<!--php+mysql二級(jí)聯(lián)動(dòng)-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>生成學(xué)院專業(yè)級(jí)聯(lián)下拉菜單測(cè)試 </title>
</head>
<body>
<&#63; //
/***********************************************
** 功 能: php+mysql+javascript實(shí)現(xiàn)學(xué)院專業(yè)二級(jí)級(jí)聯(lián)下拉框
** 數(shù)據(jù)庫(kù):數(shù)據(jù)庫(kù)名( dms)、數(shù)據(jù)表( colleges、 majors)
** 表 colleges中字段: college_id( id編號(hào))、 name(學(xué)院名)
** 表 majors中的字段: major_id( id編號(hào))、 college_id(學(xué)院 ID)、 name(學(xué)院名)
** version 1.0
** 作 者: wu yaowen
***********************************************/
//****************** 連接選擇數(shù)據(jù)庫(kù) ***************
$link = mysql_connect("localhost", "root", "123456")
  or die("Could not connect : " . mysql_error());
mysql_select_db("dms") or die("Could not select database");
//******************提取學(xué)院信息 ******************
$queryCol = "select * from colleges order by college_id ";
mysql_query("SET NAMES 'gb2312'");
$result1 = mysql_query($queryCol) or die("Query failed : " . mysql_error());
$colleges = array();
while( $row1 = mysql_fetch_array($result1) )
{
  $colleges[] = $row1;
}
//print_r ($forum_data);
mysql_free_result($result1);
//**************獲取專業(yè)信息 **************  
$queryMaj = "select * from majors order by college_id desc";
mysql_query("SET NAMES 'gb2312'");
if( !($result2 = mysql_query($queryMaj)) )
{
  die('Could not query t_city list');
}
$majors = array();
while( $row2 = mysql_fetch_array($result2) )
{
  $majors[] = $row2;
}
mysql_free_result($result2);
&#63;>
<!--************ JavaScript處理 college-onChange *************-->
<script language = "JavaScript">
 var majorCount; // 存儲(chǔ)專業(yè)記錄條數(shù)
 // form_majors[] 儲(chǔ)存專業(yè) major數(shù)據(jù),如 {(1,1,電子商務(wù) ),(4,1,計(jì)算機(jī)科學(xué) ),(3,2,古典文學(xué) )}
 form_majors = new Array();
 <&#63;php
   $num2 = count($majors); // $num2 獲取專業(yè)表中記錄的個(gè)數(shù)
 &#63;>
   majorCount = <&#63;php echo $num2;&#63;>;
 <&#63;
   for($j=0;$j<$num2;$j++) // 從 0開(kāi)始取出上面 majors[]中存儲(chǔ)的專業(yè)數(shù)據(jù)填充數(shù)組
 {
 &#63;>
   form_majors[<&#63;echo $j;&#63;>] = new Array("<&#63;echo $majors[$j]['major_id'];&#63;>","<&#63;echo $majors[$j]['college_id'];&#63;>","<&#63;echo $majors[$j]['name'];&#63;>");
 <&#63;php
 }
 &#63;>
 function changeCollege(college_id)
 {
   document.stu_add_form.major.length = 0;
   var id=id;
   var j;
   document.stu_add_form.major.options[0] = new Option('==選擇專業(yè) ==',''); // label的 value為空 ' '
   for (j=0;j < majorCount; j++) // 從 0開(kāi)始判斷
   {
    if (form_majors[j][1] == college_id) // if college_id等于選擇的學(xué)院的 id
    {
       document.stu_add_form.major.options[document.stu_add_form.major.length] = new Option(form_majors[j][2], form_majors[j][0]);
    }
   }
 }
</script>
<!--********************頁(yè)面表單 *************************-->
<form name="stu_add_form" method="post">
選擇: <select name="college" onChange="changeCollege(document.stu_add_form.college.options[document.stu_add_form.college.selectedIndex].value)" size="1">
<option selected>==請(qǐng)選擇學(xué)院 ==</option>
<&#63;php
$num = count($colleges);
for($i=0;$i<$num;$i++)
{
&#63;>
<option value="<&#63;echo $colleges[$i]['college_id'];&#63;>"><&#63;echo $colleges[$i]['name'];&#63;></option>
<&#63;
}
&#63;>
</select>
<select name="major">
<option selected value="">==選擇專業(yè) ==</option>
</select>
</form>
</body>
</html>

sql statement:

--
-- 表的結(jié)構(gòu) `colleges`
--
CREATE TABLE IF NOT EXISTS `colleges` (
 `college_id` int(8) NOT NULL auto_increment COMMENT '學(xué)院編號(hào)自動(dòng)增加',
 `name` varchar(40) NOT NULL COMMENT '學(xué)院名稱',
 PRIMARY KEY (`college_id`),
 UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312 AUTO_INCREMENT=7 ;
--
-- 導(dǎo)出表中的數(shù)據(jù) `colleges`
--
INSERT INTO `colleges` (`college_id`, `name`) VALUES
(4, '化學(xué)與化工學(xué)院'),
(1, '計(jì)算機(jī)與信息科學(xué)學(xué)院'),
(6, '美術(shù)學(xué)院'),
(2, '文學(xué)院'),
(5, '音樂(lè)學(xué)院'),
(3, '政治與公共管理學(xué)院');
--
-- 表的結(jié)構(gòu) `majors`
--
CREATE TABLE IF NOT EXISTS `majors` (
 `major_id` int(8) NOT NULL auto_increment COMMENT '專業(yè)號(hào),自動(dòng)增加',
 `name` varchar(40) NOT NULL COMMENT '專業(yè)名',
 `college_id` int(8) default NULL COMMENT '所在學(xué)院',
 `counsellor_id` int(10) default NULL COMMENT '輔導(dǎo)員',
 PRIMARY KEY (`major_id`),
 UNIQUE KEY `college_id` (`college_id`,`counsellor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312 AUTO_INCREMENT=8 ;
--
-- 導(dǎo)出表中的數(shù)據(jù) `majors`
--
INSERT INTO `majors` (`major_id`, `name`, `college_id`, `counsellor_id`) VALUES
(1, '電子商務(wù)', 1, 1),
(2, '音樂(lè)視唱', 5, 1),
(3, '古典文學(xué)', 2, 1),
(4, '計(jì)算機(jī)科學(xué)', 1, NULL),
(5, '自動(dòng)化', 1, NULL),
(6, '現(xiàn)代文學(xué)', 2, NULL),
(7, '新聞寫作', 2, NULL);

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP database operation skills based on pdo", "PHP MongoDB database operation skills collection", "php object-oriented programming introductory tutorial", "php Summary of String Usage", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of PHP Common Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125889.htmlTechArticleDetailed explanation of the effect of the secondary linkage menu implemented by php mysql. The example of mysql linkage in this article describes the secondary linkage implemented by php mysql. Menu effects. Share it with everyone for your reference, the details are as follows: !-...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Why We Comment: A PHP Guide Why We Comment: A PHP Guide Jul 15, 2025 am 02:48 AM

PHPhasthreecommentstyles://,#forsingle-lineand/.../formulti-line.Usecommentstoexplainwhycodeexists,notwhatitdoes.MarkTODO/FIXMEitemsanddisablecodetemporarilyduringdebugging.Avoidover-commentingsimplelogic.Writeconcise,grammaticallycorrectcommentsandu

How to Install PHP on Windows How to Install PHP on Windows Jul 15, 2025 am 02:46 AM

The key steps to install PHP on Windows include: 1. Download the appropriate PHP version and decompress it. It is recommended to use ThreadSafe version with Apache or NonThreadSafe version with Nginx; 2. Configure the php.ini file and rename php.ini-development or php.ini-production to php.ini; 3. Add the PHP path to the system environment variable Path for command line use; 4. Test whether PHP is installed successfully, execute php-v through the command line and run the built-in server to test the parsing capabilities; 5. If you use Apache, you need to configure P in httpd.conf

PHP Syntax: The Basics PHP Syntax: The Basics Jul 15, 2025 am 02:46 AM

The basic syntax of PHP includes four key points: 1. The PHP tag must be ended, and the use of complete tags is recommended; 2. Echo and print are commonly used for output content, among which echo supports multiple parameters and is more efficient; 3. The annotation methods include //, # and //, to improve code readability; 4. Each statement must end with a semicolon, and spaces and line breaks do not affect execution but affect readability. Mastering these basic rules can help write clear and stable PHP code.

python if else example python if else example Jul 15, 2025 am 02:55 AM

The key to writing Python's ifelse statements is to understand the logical structure and details. 1. The infrastructure is to execute a piece of code if conditions are established, otherwise the else part is executed, else is optional; 2. Multi-condition judgment is implemented with elif, and it is executed sequentially and stopped once it is met; 3. Nested if is used for further subdivision judgment, it is recommended not to exceed two layers; 4. A ternary expression can be used to replace simple ifelse in a simple scenario. Only by paying attention to indentation, conditional order and logical integrity can we write clear and stable judgment codes.

PHP 8 Installation Guide PHP 8 Installation Guide Jul 16, 2025 am 03:41 AM

The steps to install PHP8 on Ubuntu are: 1. Update the software package list; 2. Install PHP8 and basic components; 3. Check the version to confirm that the installation is successful; 4. Install additional modules as needed. Windows users can download and decompress the ZIP package, then modify the configuration file, enable extensions, and add the path to environment variables. macOS users recommend using Homebrew to install, and perform steps such as adding tap, installing PHP8, setting the default version and verifying the version. Although the installation methods are different under different systems, the process is clear, so you can choose the right method according to the purpose.

Your First PHP Script: A Practical Introduction Your First PHP Script: A Practical Introduction Jul 16, 2025 am 03:42 AM

How to start writing your first PHP script? First, set up the local development environment, install XAMPP/MAMP/LAMP, and use a text editor to understand the server's running principle. Secondly, create a file called hello.php, enter the basic code and run the test. Third, learn to use PHP and HTML to achieve dynamic content output. Finally, pay attention to common errors such as missing semicolons, citation issues, and file extension errors, and enable error reports for debugging.

What is PHP and What is it Used For? What is PHP and What is it Used For? Jul 16, 2025 am 03:45 AM

PHPisaserver-sidescriptinglanguageusedforwebdevelopment,especiallyfordynamicwebsitesandCMSplatformslikeWordPress.Itrunsontheserver,processesdata,interactswithdatabases,andsendsHTMLtobrowsers.Commonusesincludeuserauthentication,e-commerceplatforms,for

How Do You Handle File Operations (Reading/Writing) in PHP? How Do You Handle File Operations (Reading/Writing) in PHP? Jul 16, 2025 am 03:48 AM

TohandlefileoperationsinPHP,useappropriatefunctionsandmodes.1.Toreadafile,usefile_get_contents()forsmallfilesorfgets()inaloopforline-by-lineprocessing.2.Towritetoafile,usefile_put_contents()forsimplewritesorappendingwiththeFILE_APPENDflag,orfwrite()w

See all articles