php+ajax 城市联动
php+ajax城市联动 ?php /* 表结构---- 表的结构 `web_city`--CREATE TABLE IF NOT EXISTS `web_city` ( `id` mediumint(8) NOT NULL AUTO_INCREMENT, `title` varchar(60) NOT NULL, `pid` mediumint(8) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=M
php+ajax 城市联动
<?php /* 表结构 -- -- 表的结构 `web_city` -- CREATE TABLE IF NOT EXISTS `web_city` ( `id` mediumint(8) NOT NULL AUTO_INCREMENT, `title` varchar(60) NOT NULL, `pid` mediumint(8) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; -- -- 转存表中的数据 `web_city` -- INSERT INTO `web_city` (`id`, `title`, `pid`) VALUES (1, '北京', 0), (2, '东单', 1), (3, '西单', 1); */ $my_db = mysql_connect("localhost","root",""); mysql_select_db("city", $my_db); mysql_query("set names 'utf8'"); $sql = "select * from web_city where pid = 0"; $query = mysql_query($sql); $provice = array(); while($row = mysql_fetch_assoc($query)) { $provice[] = $row; } ?> <!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>php+ajax 城市联动</title> <script src="jquery-1.8.0.min.js"></script> </head> <body> <script> function select_city(){ var id = jQuery("#provice option:selected").val(); $("#city").html('<option value="">选择市</option>'); $.ajax({ type: "post", url: "ajax.php", data: "id="+id, dataType: "json", success: function(msg){ var tbody = ""; $.each(msg.optionss,function(n,value){ var trs = ""; trs += "<option value='"+ value.id +"'>"+value.title+"</option>"; tbody += trs; }) $("#city").append(tbody); } }); } </script> <div> <select name="provice" id="provice" onchange="select_city()"> <option value="">选择省/市</option> <?php foreach($provice as $val){?> <option value="<?php echo $val['id'];?>"><?php echo $val['title'];?></option> <?php }?> </select> <select name="city" id="city"> <option value="">选择市</option> </select> </div> </body> </html>
<?php $my_db = mysql_connect("localhost","root",""); mysql_select_db("city", $my_db); mysql_query("set names 'utf8'"); if(isset($_POST['id'])){ $id = $_POST['id']; $sql_city = "select * from web_city where pid = $id"; $query_city = mysql_query($sql_city); $city = array(); while($row = mysql_fetch_assoc($query_city)) { $city[] = $row; } echo json_encode(array('optionss'=>$city)); } ?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Journey through the vastness and set foot on the journey to the west! Today, Zhengtu IP officially announced that it will launch a cross-border cooperation with CCTV animation "Journey to the West" to jointly create a cultural feast that combines tradition and innovation! This cooperation not only marks the in-depth cooperation between the two major domestic classic brands, but also demonstrates the unremitting efforts and persistence of the Zhengtu series on the road of promoting Chinese traditional culture. Since its birth, the Zhengtu series has been loved by players for its profound cultural heritage and diversified gameplay. In terms of cultural inheritance, the Zhengtu series has always maintained respect and love for traditional Chinese culture, and skillfully integrated traditional cultural elements into the game, bringing more fun and inspiration to players. The CCTV animation "Journey to the West" is a classic that has accompanied the growth of generations.

There are many treasure chests in Mingchao Jinzhou City. Many players want to know where the treasure chests are. The editor has marked the locations of all the treasure chests. Players can just follow the marked numbers to find them one by one. Let’s take a look at this Mingchao article for details. The latest collection of all treasure chests in Jinzhou City. Mingchao Strategy Collection Mingchao Jinzhou City Treasure Box Collection Location 1: Jinzhou City (1-25) Twenty-five treasure boxes, five voice boxes Location 2: Jinzhou City (26-41) Fifteen treasure boxes, three A voice box, two flying hunters

On the date, "Backwater Cold" officially announced that it will launch a linkage with KFC from April 19th to May 12th. However, the specific content of the linkage has left many people stunned. They repeatedly said, "It's embarrassing to heaven" and "It's important to society." died"! The reason lies in the slogan of this theme event. Friends who have seen the KFC linkage of "Genshin Impact" and "Beng Tie" must have the impression that "encountering another world and enjoying delicious food" has become a reality in "Ni Shui Han" Now: shout out to the clerk, "God is investigating the case, who are you?" The clerk needs to reply, "Fried chicken is a big business, and there is no room for error!" Training guide for employees: Never laugh! Not only that, this collaboration also held a dance competition. If you go to the theme store and perform the "Dance when you hear 'Ji'" dance move, you can also get a small rocking music stand. Embarrassing, so embarrassing! But that's what I want

NetEase's "Onmyoji" mobile game announced today that the Onmyoji x Hatsune Miku limited collaboration will officially begin on March 6. The collaboration-limited SSR Hatsune Miku (CV: Saki Fujita) and SSR Kagamine Rin (CV: Asami Shimoda) are coming to Heian Kyo! The linkage online special performance event will officially start in the game on March 9~

Classic reunion, reversing time and space. The "Dragon 2" mobile game and the classic movie "Westward Journey" are jointly scheduled to be released on April 11! It coincides with the anniversary celebration of the "Dragon 2" mobile game. We invite everyone to relive the classic memories and once again witness the battle between Zhizunbao and Zixia until death. The legendary story of Chongqing. There must be colorful auspicious clouds, and there must be golden armor and holy clothes. When the phrase "Prajna Paramita" echoes in your ears, will you think of the tear that Zixia left in the heart of the Supreme Treasure? A glance for ten thousand years, but it is impossible to escape the fate of fate. Even if there is no return, my love will never change until death. The Westward Journey collaboration appearance [One Eye for Ten Thousand Years] and [God's Will] will be launched simultaneously with the anniversary version. I hope you can wear the golden armor or meet your own unparalleled hero, and return to your most passionate youth. Five hundred years of protection, true love till death, said by chance when I met Luoyang that day

Introduction to the linkage and dependency functions of Java development form fields: In Web development, forms are a frequently used interaction method. Users can fill in information and submit it through the form, but cumbersome and redundant form field selection operations often cause problems for users. bring inconvenience. Therefore, the linkage and dependency functions of form fields are widely used to improve user experience and operational efficiency. This article will introduce how to use Java development to implement linkage and dependency functions of form fields, and provide corresponding code examples. 1. Implementation form of form field linkage function

NetEase Games announced today that "Diablo: Immortal" has decided to link up with "Legend of Sword and Fairy". On April 24th, "One Sword is Happy" opens a new era of immortal cultivation! One is a classic of Western fantasy, and the other is the eternal memory of Eastern immortals. The dark universe and the fairy sword are intertwined in time and space, and the two major IPs work together to slay demons. On April 24th, the immortal legend of justice and chivalry will be staged in Sanctuary!

Yuanmeng Star Ultraman genuine linkage series, Zero Zeta's same fashion details are revealed today. I believe everyone has been looking forward to it for a long time. The co-branded fashion with Zero Zeta has been launched today. Follow the editor to take a look at this I hope it can help you with more details about the Ultraman link-up. Yuanmeng Star Ultraman genuine linkage: Zero Zeta resonates with the power of Ultra, bursting out with sparks of passion! As a new generation of young Ultra Warriors in the Kingdom of Light, Ultraman Zero is the captain of the Ultimate Zero Guard. Ultraman Zero is uninhibited, kind, passionate and unrestrained. "Aren't you still at ease with me by your side? Zero will do his best to protect you." Star treasures, star treasures, put on Ultraman Zero's costumes and fight bravely with Zero! Detailed display, modeling action, appearance action, standby action, Zeta, I am not a one-third dabbler, I am the universe
