Hiya Guys,
I’m trying to create a simple XML string from a MySQL database via PHP.
Currently I have a MySQL database built, and am using this function, which is working well:
function createxml($x) {
global $mysqli;
include(‘xml.php’);
$sxe = new SimpleXMLElement($xmlstr);
//get mysql data
if ($result = $mysqli->query(“SELECT id,county,main_page,lat,lon,volume,texty,pdf,thumb FROM texts3 ORDER BY id ASC LIMIT $x”))
{
//found volumes already in DB
while ($r = $result->fetch_array(MYSQLI_BOTH)) {
$record = $sxe->addChild(‘record’);
$record->addChild(‘title’, $r[‘county’]);
$record->addChild(‘creator’, ‘’);
$record->addChild(‘description’, $r[‘texty’]);
$record->addChild(‘latitude’, $r[‘lat’]);
$record->addChild(‘longitude’, $r[‘lon’]);
$record->addChild(‘latlon’, $r[]);
$record->addChild(‘identifier’, $r[‘id’]);
$record->addChild(‘isShownAt’, ‘http://griffiths.askaboutireland.ie/gv4/nbl/lh_nbl_show3.php?id=’.$r['id’]);
$record->addChild(‘thumb’, ‘http://griffiths.com/gv4/’.$r['thumb’]);
$record->addChild(‘publisher’, ‘askaboutireland.ie’);
$record->addChild(‘date’, date(‘Y’));
$record->addChild(‘format’, ‘TEXT’);
$record->addChild(‘spatial’, ‘’);
$record->addChild(‘provider’, ');
$record->addChild(‘rights’, 'All rights reserved. ');
$record->addChild(‘subject’, ‘name books and letters,’);
}
$result->close();
}
What I am trying to do is very simple: for the ‘latlon’ variable, I would simply like $lat and $lon to be combined.
So it would be ouputed, in normal PHP, like: $latlon = $lat. “,”. $lon;
How would I combine these two elements in to be outputted in the XML?