PHP 23rd session

Source: Internet
Author: User

Xml

XML: Passing data between pages, passing across platforms

HTML: Hypertext Markup Language, core tags

XML Features:
1. Tag name can be defined by itself
2. There is only one root
3. Case sensitive
4. The label must be complete

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<script src= ". /jquery-1.11.2.min.js "></script>

<body>
<select id= "SEL" >
</select>
</body>
<script type= "Text/javascript" >
$ (document). Ready (function (e) {

$.ajax ({
URL: "chuli.php",
DataType: "JSON",
Success:function (data) {

alert (data);
var str = "";
For (var k in data)
{
str+= "<option value= '" +data[k][0]+ ">" +data[k][1]+ "</option>";
}

$ ("#sel"). html (str);

}
});

});
</script>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<script src= ". /jquery-1.11.2.min.js "></script>

<body>
<select id= "SEL" ></select>
</body>
<script type= "Text/javascript" >
$ (document). Ready (function (e) {

$.ajax ({
URL: "chulixml.php",
DataType: "XML",
Success:function (data) {

var ch = $ (data). Find ("Nation"). Children ();
var str = "";
for (Var i=0;i<ch.length;i++)
{
var code = $ (Ch[i]). Find ("code"). Text ();
var name = $ (ch[i]). Find ("name"). Text ();

str+= "<option value= '" +code+ ">" +name+ "</option>";
}
$ ("#sel"). html (str);

}
});
});
</script>

<?php
Include (".. /dbda.php ");
$db = new Dbda ();

$sql = "SELECT * from Nation";

$attr = $db->query ($sql);


echo "<nation>";

foreach ($attr as $k = $v)
{
echo "<shuju{$k}>";

echo "<code>{$v [0]}</code>";
echo "<name>{$v [1]}</name>";

echo "</shuju{$k}>";
}

echo "</nation>";

<?php

Include (".. /dbda.php ");
$db = new Dbda ();

$sql = "SELECT * from Nation";
$attr = $db->query ($sql);

echo Json_encode ($attr);

?>

PHP 23rd session

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.