PHP ile XML SQLite

0 Cevap php

I am sure this can be done. I need to pull data from a SQLite db & convert it to XML on the fly, so it can be read by fusioncharts to display pretty graphs.

Ben mysql ile yapılır ama zor XML SQLite hakkında bilgi bulmakta yaşıyorum gördük.

<?php 

header("Content-type: text/xml"); 

$host = "localhost"; 
$user = "root"; 
$pass = ""; 
$database = "test"; 

$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
mysql_select_db($database, $linkID) or die("Could not find database."); 

$query = "SELECT * FROM blog ORDER BY date DESC"; 
$resultID = mysql_query($query, $linkID) or die("Data not found."); 

$xml_output = "<?xml version=\"1.0\"?>\n"; 
$xml_output .= "<entries>\n"; 

for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ 
    $row = mysql_fetch_assoc($resultID); 
    $xml_output .= "\t<entry>\n"; 
    $xml_output .= "\t\t<date>" . $row['date'] . "</date>\n"; 
        // Escaping illegal characters 
        $row['text'] = str_replace("&", "&", $row['text']); 
        $row['text'] = str_replace("<", "<", $row['text']); 
        $row['text'] = str_replace(">", "&gt;", $row['text']); 
        $row['text'] = str_replace("\"", "&quot;", $row['text']); 
    $xml_output .= "\t\t<text>" . $row['text'] . "</text>\n"; 
    $xml_output .= "\t</entry>\n"; 
} 

$xml_output .= "</entries>"; 

echo $xml_output; 

http://www.kirupa.com/web/mysql_xml_php.htm alınan

Şimdiden teşekkürler.

0 Cevap