<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "user";
$pass = "lozinka";
$database = "baza";
$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 tabela";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = '<' . '?' . 'xml version="1.0" ' . '?' . '>';
$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<ID>" . $row['ID'] . "</ID>\n";
// Escaping illegal characters
htmlentities();
$row['text'] = str_replace("&", "&", $row['text']);
$row['text'] = str_replace("<", "<", $row['text']);
$row['text'] = str_replace(">", ">", $row['text']);
$row['text'] = str_replace("\", """, $row['text']);
htmlentities();
$xml_output .= "\t\t<text>" . $row['text'] . "</text>\n";
$xml_output .= "\t</entry>\n";
}
$xml_output .= "</entries>";
htmlentities();
echo $xml_output;
?>
Takdoje sam sada video da kada stavim decimlnu tip podataka za latitude i longitude onda se u bazi upise kao 0.440000 a treba da se upise kao 44.3421344... ???
|