PHP operation xml code. Copy the code as follows: * get the image News list * functiongetPicNews ($ number5) {require_once1_decontent_class.php; $ ContentnewContent (); $ sqlselectcontentidas
The code is as follows:
/* Obtain the image News list */
Function getPicNews ($ number = 5 ){
Require_once 'include/content_class.php ';
$ Content = new Content ();
$ SQL = 'SELECT contentid as id, title, pic, typeid from 'cms _ content' where pic <> "order by input_time desc ';
$ Rows = $ Content-> getRowsBySQL ($ SQL, $ number );
$ Dom = new DOMDocument ('1. 0', 'gbk ');
$ Root = $ dom-> createElement ('Slider ');
$ Dom-> appendChild ($ root );
Foreach ($ rows as $ val ){
$ Item = $ dom-> createElement ('ITEM ');
$ Root-> appendChild ($ item );
$ Title = $ dom-> createAttribute ('title ');
$ Title_text = $ dom-> createTextNode ($ val ['title']);
$ Title-> appendChild ($ title_text );
$ Item-> appendChild ($ title );
$ Href = $ dom-> createAttribute ('href ');
$ Href_text = $ dom-> createTextNode ('Show. php? Newsid = '. $ val ['id'].' & classid = '. $ val ['typeid']);
$ Href-> appendChild ($ href_text );
$ Item-> appendChild ($ href );
$ Imageurl = $ dom-> createAttribute ('imageurl ');
$ Imageurl_text = $ dom-> createTextNode ($ val ['Pic ']);
$ Imageurl-> appendChild ($ imageurl_text );
$ Item-> appendChild ($ imageurl );
}
Return $ dom-> saveXML ();
}
The http://www.bkjia.com/PHPjc/321949.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321949.htmlTechArticle code is as follows:/* get Picture News list */function getPicNews ($ number = 5) {require_once 'include/content_class.php '; $ Content = new Content (); $ SQL = 'SELECT contentid...