Hi all. My first time here.
I’m very new to PHP, but am having trouble with this project. My task (given by myself) is to pull product information from a product database (OpenCart) and plonk it into an XML file.
What I still need to do with the file that I’m struggling with:
It needs to generate the .xml file in the root directory where the .php file is
It needs to generate the file at 9pm every night
This is my .php file so far
Code:<?php header('Content-type: text/xml'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="products.xml"'); // connect to database $db_name = "database"; $connection = mysql_connect("localhost", "user", "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_description 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[7]) ." ]]></ProductCode> <Title><![CDATA[ ". htmlentities($row[2]) ." ]]></Title> <Category><![CDATA[ categories ]]></Category> <Price>". htmlentities($row[14]) ."</Price> <Quantity>". htmlentities($row[9]) ."</Quantity> <Condition>New</Condition> <Location>Cape Town</Location> <ShippingOption>Speed Services</ShippingOption> <ImageURL><![ CDATA[ http://www.digitalsushi.co.za/image/". htmlentities($row[11]) ." ]]></ImageURL> <Description><![CDATA[ ".html_entity_decode($row[5]) ." ]]></Description> </Product> "; } $buf .= "</Products> </ROOT>"; echo $buf; mysql_close($connection);; $buf=""; ?>
Can anyone help me with this?



Reply With Quote

Bookmarks