我的情況是,我不能夠寫代碼,請告訴我..我要重新設計的XML結構
我想在XML中1個產品展示 - >第1類 - >許多子類別如果類別改變,然後1產品 - >第二類 - > 2 SubCategories等..產品總是1產品沒有改變..
1產品基於XML。
請幫我...
以下是目前的結構:
<?
include_once("./inc/config.php");
include_once("jsAdminMethods.php");
$productID = $_POST['productID'];
//echo $productID;
$productQuery = mysql_query("select a.productId, a.productName, a.productAbout, a.productPic, aa.categoryID, aa.categoryName, aa.categoryDiscription, aa.categoryPic, l.subCategoryID, l.subCategoryName, l.subCategoryDescription from category aa, product a, subCategory l where a.productID = aa.productID and l.categoryID = aa.categoryID and a.productID = $productID");
$num = mysql_num_rows($productQuery);
if(!$num == 0){
$_fileName ="";
$file= fopen("../xml/{$productID}.xml" , "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
$_XML = "<!DOCTYPE Server SYSTEM \"opt/pdos/etc/pdoslrd.dtd\">";
$_xml .="<cmm>";
while ($row = mysql_fetch_array($productQuery, MYSQL_ASSOC)) {
$_xml .=" <product>";
$_xml .=" <productID>" . $row['productId'] . "</productID>";
$_xml .=" <productName><![CDATA[" . htmlspecialchars($row['productName'],ENT_QUOTES) . "]]></productName>";
$_xml .=" <productDescription><![CDATA[" . htmlspecialchars($row['productAbout'],ENT_QUOTES) . "]]></productDescription>";
$_xml .=" <productPicture><![CDATA[" . htmlspecialchars($row['productPic'],ENT_QUOTES) . "]]></productPicture>";
$_xml .=" <category>";
$_xml .=" <categoryID>" . $row['categoryID'] . "</categoryID>";
$_xml .=" <categoryName><![CDATA[" . htmlspecialchars($row['categoryName'],ENT_QUOTES) . "]]></categoryName>";
$_xml .=" <categoryDescription><![CDATA[" . htmlspecialchars($row['categoryDiscription']) . "]]></categoryDescription>";
$_xml .=" <categoryPicture><![CDATA[" . htmlspecialchars($row['categoryPic'],ENT_QUOTES) . "]]></categoryPicture>";
$_xml .=" <subCategory>";
$_xml .=" <subCategoryID>" . $row['subCategoryID'] . "</subCategoryID>";
$_xml .=" <subCategoryName><![CDATA[" . htmlspecialchars($row['subCategoryName'],ENT_QUOTES) . "]]></subCategoryName>";
$_xml .=" <subCategoryDetail><![CDATA[" . htmlspecialchars($row['subCategoryDescription'],ENT_QUOTES) . "]]></subCategoryDetail>";
$_xml .=" </subCategory>";
$_xml .=" </category>";
$_xml .=" </product>";
}
$_xml .="</cmm>";
fwrite($file, $_xml);
fclose($file);
$value = "product XML Generted Successfully";
$tagproductXML = md5($value);
header("location:xmlGenerator.php?tagproductXML=$tagproductXML");
}
else{
echo "No Records found in xml";
}
?>
您能向我們展示您在此處運行的SQL嗎?表結構也很方便。 – Charles 2011-03-21 18:20:43
編輯問題中的sql – 2011-03-21 19:06:46