Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/01/2007, 14:30
Avatar de humanista
humanista
 
Fecha de Ingreso: abril-2005
Mensajes: 878
Antigüedad: 19 años, 10 meses
Puntos: 15
Re: empezando con xml

te refieres a esto?

<?
$db_direccion = 'XX.XXX.XXX.XX';
$db_user = 'Xxxxxxxx';
$db_pass = '********';
$db_name = 'Xxxxxxxx';
$db_table = 'phpnews_news';
$db_campo_fecha = 'time';
$db_campo_titulo = 'subject';
$db_campo_texto = 'maintext';
$db_campo_url = 'id';
$pg_titulo = 'PEÓNDEDAMA.COM - AJEDREZ DIGITAL';
$pg_autor = 'Copyleft - Manel García 2006';
$pg_link = 'http://www.peondedama.com';
$pg_descripcion = 'Noticias y otras cosas sobre Ajedrez...';
$pg_idioma = 'es';
if ( isset ($_REQUEST['perPage']) ){
$perPage = $_REQUEST['perPage'];
} else {
$perPage = 13;
}
header( "Content-type: text/xml");
echo '<'; ?>?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
<title><?=$pg_titulo?></title>
<editor_noticias><?=$pg_autor?></editor_noticias>
<link><?=$pg_link?></link>
<description><?=$pg_descripcion?></description>
<language><?=$pg_idioma?></language>
<?
mysql_connect($db_direccion,$db_user,$db_pass);
mysql_select_db($db_name);
$sql="SELECT * FROM $db_table ORDER BY $db_campo_fecha DESC LIMIT 0,$perPage";
$qry = mysql_query($sql);
if (mysql_num_rows($qry))
while ($row=mysql_fetch_array($qry)){
echo "\n";
echo " <item>\n";
echo " <title>".$row[$db_campo_titulo]."</title>\n";
$desc = str_replace("\n",'',$row[$db_campo_texto]);
$desc = str_replace("\r",'',$desc);
$desc = substr($desc,0,999);
$desc = htmlentities($desc);
echo " <description>".$desc."</description>\n";
echo " <link>http://www.peondedama.com/index.php?action=fullnews?id=".$row['id']."</link>\n";
echo " </item>\n";
}
?>
</channel>
</rss>