ok, i have a php file that creates an xml file from orders. i am eventualy going to export that xml file to the distributor for order processing. the creation of the xml file is going good, however once i got past the customer order information, name address etc., i needed to add the product being ordered. problem is that the information is located in a different table and my query skills with xml are a little rusty. I will post the code with what i have, and show you what i need. the fields i need are in the text "NEED THIS INFO" ( i left out the connection string info for the db)
PHP Code:
$table_name = 'zen_orders';
$db = mysql_select_db($db_name);
$query = "select * from " . $table_name;
$result = mysql_query($query, $connection) or die("Could not complete database query");
$num = mysql_num_rows($result);
if ($num != 0) {
$file= fopen("results.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .="<OrderList>\r\n";
while ($row = mysql_fetch_array($result)) {
if ($row["orders_id"]) {
$_xml .="\t<Order id=\"" . $row["orders_id"] . "\">\r\n";
$_xml .="\t\t<Shipping>Budget</Shipping>\r\n";
$_xml .="\t\t\t<Addressinfo type='ship'>\r\n";
$_xml .="\t\t<Name>" . $row["delivery_name"] . "</Name>\r\n";
$_xml .="\t\t<Company>" . $row["delivery_company"] . "</Company>\r\n";
$_xml .="\t\t<Address1>" . $row["delivery_street_address"] . "</Address1>\r\n";
$_xml .="\t\t<City>" . $row["delivery_city"] . "</City>\r\n";
$_xml .="\t\t<State>" . $row["delivery_state"] . "</State>\r\n";
$_xml .="\t\t<Country>" . $row["delivery_country"] . "</Country>\r\n";
$_xml .="\t\t<Zip>" . $row["delivery_zip"] . "</Zip>\r\n";
$_xml .="\t\t<Item>\r\n";
$_xml .="\t\t<Id>" . $row["NEED THIS INFO"] . "</Id>\r\n";
$_xml .="\t\t<Quantity>" . $row["NEED THIS INFO"] . "</Quantity>\r\n";
$_xml .="\t\t</Item>\r\n";
$_xml .="\t\t\t</Addressinfo>\r\n";
$_xml .="\t</Order>\r\n";
} else {
$_xml .="\t<order id=\"Nothing Returned\">\r\n";
$_xml .="\t\t<file>none</file>\r\n";
$_xml .="\t</order>\r\n";
} }
$_xml .="</OrderList>";
fwrite($file, $_xml);
fclose($file);
echo "XML has been written. <a href=\"results.xml\">View the XML.</a>";
} else {
echo "No Records found";
} ?>
basically i need the quantity ordered and product id from the zen_orders_products table. i know someone has an idea on how to do this. This is also starting to look like a nice mod as well.