Hi,
right at the beginning I want to excuse if this was discussed elsewhere in the forum. But since it's not impossible in the forum to search for words with three chars, XML and SQL is hard to find. So, sorry for possible double posting.
I'm trying to create a XML-file from the following Infos:
- imageID
- imagetitle
- imagefilename
- thumbfilename
- description
and last but the main problem
Since the name of the category is in an other table I'm stuck how to get the name.... I took the
Flash Gallery Addon and modified the xml generator. So here is my result
PHP Code:
<?php
if( $_GET['view']!='addons' ) {
header('Content-Type: text/xml; charset=utf-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
require("includes/pixelpost.php");
require("includes/functions.php");
start_mysql('includes/pixelpost.php','front');
$cfgrow = sql_array("SELECT * FROM ".$pixelpost_db_prefix."config");
$tz = $cfgrow['timezone'];
$datetime = gmdate("Y-m-d H:i:s",time()+(3600 * $tz)); // current date+time
$cdate = $datetime; // for future posting, current date+time
$i = 1;
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gallery title="'.htmlspecialchars($cfgrow['sitetitle']).'" thumbDir="./images/" imageDir="./images/">'.PHP_EOL;
$query2 = "SELECT count(*) AS slides FROM {$pixelpost_db_prefix}catassoc AS CAT INNER JOIN {$pixelpost_db_prefix}pixelpost AS PIX ON (CAT.image_id = PIX.id) WHERE (datetime<='".$cdate."')";
$query2 = mysql_query($query2);
$row2 = mysql_fetch_array($query2);
if ( $row2['slides'] != 0 ) {
$query2 = "SELECT distinct(PIX.id), PIX.image, PIX.headline, PIX.body, PIX.datetime, PIX.category
FROM {$pixelpost_db_prefix}catassoc AS CAT
INNER JOIN {$pixelpost_db_prefix}pixelpost AS PIX ON (CAT.image_id = PIX.id)
WHERE (datetime<='".$cdate."')
ORDER BY datetime DESC";
$query2 = mysql_query($query2);
while($row2 = mysql_fetch_array($query2)){
echo '<image id="'.$row2['id'].'"';
if (file_exists(dirname(dirname($_SERVER['SCRIPT_FILENAME'])).'/images/fullsize_'.utf8_encode($row2['image']))) {
echo ' img ="fullsize_'.utf8_encode($row2['image']).'"';
}
else {
echo ' img="'.utf8_encode($row2['image']).'"';
}
echo' thumb="'.utf8_encode($row2['image']).'" ' .
'title="'.utf8_encode(htmlspecialchars($row2['headline'])).'" ' .
'desc="'.utf8_encode((htmlspecialchars($row2['body']))).'" ' .
'date="'.utf8_encode($row2['datetime']).'" ' .
'category="'.utf8_encode($row2['category']).'"/>'.PHP_EOL;
}
}
echo'</gallery>';
}
?>
so I now get the id of the category but not the Name.
Since I'm kind of 'untrained' in building SQL statements I hope you could help me.
Thank you and greetings from Berlin
Frank