Hi im trying to access a field from a mysql table results from a url eg localhost/test.php=id=2
btw im noob to xml and php so please excuse me for that..
any suggestions or tutorials would be gratefully appreciated..
heres the code im working on
<?php
header("Content-Type: text/xml");
$xmlBody = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$xmlBody .= "<XML>";
$dbhost = 'localhost:3036';
$dbuser = 'nas';
$dbpass = 'root';
mysql_select_db('db_home') or die("no database");
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error());
$sql = mysql_query("SELECT * FROM table_gas ORDER BY datetime DESC LIMIT 0, 20");
while($row = mysql_fetch_array($sql)){
$id = $row["gas_id"];
$timestamp = $row["timestamp"];
$value = $row["value"];
$datetime = strftime("%b %d, %Y", strtotime($row["datetime"]));
$xmlBody .= '
<Data>
<DataID>' . $id . '</DataID>
<DataTime>' . $timestamp . '</DataTime>
<DataValue>' . $value . '</DataValue>
<DataTime>' . $datetime . '</DataTime>
</Data>';
}
mysql_close();
$xmlBody .= "</XML>";
echo $xmlBody;
?>
when i put this into the address bar local/xmltest.php?DataID=2 i get a blank screen..