This is what I have so far:
Code: Select all
<?php
header('Content-type: text/xml');
// It will be called digitalsushiitems.xml
header('Content-Disposition: attachment; filename="digitalsushiitems.xml"');
// connect to database
$db_name = "database";
$connection = mysql_connect("localhost", "username", "password") or die("Could not connect.");
// querying mysql
$db = mysql_select_db($db_name, $connection) or die("Could not connect.");;
$result = mysql_query("SELECT * FROM product_selection NATURAL JOIN product");
// XML File Creation
$buf ='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ROOT>
<Products>
';
while($row=mysql_fetch_array($result)) {
$buf .= "<Product>
<ProductCode><![CDATA[ ".htmlentities($row[2]) ." ]]></ProductCode>
<Title><![CDATA[ ". htmlentities($row2[26]) ." ]]></Title>
<Category><![CDATA[ ". htmlentities($row[5]) ." ]]></Category>
<Price>no</Price>
<Quantity>". htmlentities($row[5]) ."</Quantity>
<Condition>New</Condition>
<Location></Location>
<ShippingOption>Speed Services</ShippingOption>
<ImageURL><![ CDATA[ http://www.digitalsushi.co.za/image/". htmlentities($row[6]) ." ]]></ImageURL>
<Description><![CDATA[ ". htmlentities($row2[27]) ." ]]></Description>
</Product>
";
}
$buf .= "</Products>
</ROOT>";
echo $buf;
mysql_close($connection);;
$buf="";
?>
1. Having it generate a .xml file (lets say bob.xml) in the root of the folder as well as generating a downloadable version when you access the .php file
2. Combining the data from 2 tables and then displaying all of it. These are the 2 tables:
Product and product_description. Both of them have a common variable which is product_id, but product description only has 2 (out of 4) columns that I need.
3. Having it repeat the process for each product id that exists in the product table.
Can anyone here help me? This may benifit others in my position.