Pogledajte određenu poruku
Staro 25. 05. 2011.   #46
AdriaMart
expert
Expert
 
Avatar AdriaMart
 
Datum učlanjenja: 15.03.2011
Poruke: 518
Hvala: 16
20 "Hvala" u 17 poruka
AdriaMart is on a distinguished road
Default

<?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("<", "&lt;", $row['text']);
$row['text'] = str_replace(">", "&gt;", $row['text']);
$row['text'] = str_replace("\", "&quot;", $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... ???
AdriaMart je offline   Odgovorite uz citat