<?php header("Content-Type: text/xml"); $conn = mysql_connect("localhost", "root", "mysql"); $db = mysql_select_db("my_pa"); $sql = "SELECT title FROM pa_article ORDER BY id DESC limit 5"; $query = mysql_query($sql); $data = array(); while($r=mysql_fetch_array($query,MYSQL_ASSOC)){ $data[] = $r['title']; } echo "<?xml version=/"1.0/" encoding=/"ISO-8859-1/"?>"; echo "<m>"; for($i=0; $i<count($data); $i++){ echo "<message>".$data[$i]."</message>"; } echo "</m>"; ?>