Hi,
Totally untested, but something like this should work: (I havn't written any PHP code in over 2 years, so appologies if its not fully working =))
Code:
<?php
require("phpsqlajax_dbinfo.php");
global $CatID; function parseToXML($htmlStr) {
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Opens a connection to a mySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active mySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM glinks_CatLinks,glinks_Links WHERE glinks_CatLinks.CategoryID = '$CatID' "; $result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'Title="' . parseToXML($row['Title']) . '" ';
echo 'Price="' . parseToXML($row['Price']) . '" ';
echo 'Year="' . parseToXML($row['Year']) . '" ';
echo 'Axles="' . parseToXML($row['Axles']) . '" ';
echo 'Berths="' . parseToXML($row['Berths']) . '" ';
echo 'Latitude="' . $row['Latitude'] . '" ';
echo 'Longitude="' . $row['Longitude'] . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
?>
Also, be sure to edit your HTML on the bit that call's the PHP script - so it looks like:
Code:
GDownloadUrl("phpsqlajax_genxml2.php
?CatID=<%category_id%>", function(data) {
I'm hoping <%category_id%> is the correct tag - afraid I don't have time to check it out fully, as it would require me setting up a test site, with all the longitude and latitude fields.
Hope that helps.
Cheers
Andy (mod)
andy@ultranerds.com Merry Xmas and a Happy New Year!
Want to give me something back for my help? Please see my
Amazon Wish List GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500) Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin |
Pre-Made Template Sets |
FREE GLinks Plugins! Custom Toolbar for IE and Firefox! -
Compare our different Plugin packages *new*
Free CSS Templates