In Progress

mysql Category structure, output to XMLtree with PHP

We need someone to work on our almost finished script, so it can extract what's inside the database, and put it into an XML file. (Keeping the "category/directory structure".)

The database should consist of 2 tables. 1 with 'Categories', and 1 with 'Files'.

When the code is executed, everything inside the 'Files' table should be outputted to an XML file, based on where it is according to the 'Categories' table.

The Files table should consist of NAME, DESCRIPTION, URL (most importantly)

The output should look like this:

<?xml version="1.0" encoding="iso-8859-1"?>

<node LABEL="Category 1">

.<node LABEL="Category 1 - Part 1">

..<node LABEL="OpenSoftware 4.2" URL="opensoftware42.exe" />

..<node LABEL="OpenSoftware 3.0b" URL="opensoftware30b.exe" />

..<node LABEL="OpenSoftware 2.0" URL="opensoftware30b.exe" />

.</node>

.<node LABEL="Category 1 - Part 2">

..<node LABEL="ClosedSoftware 1.0" URL="ClosedSoftware10.exe" />

..<node LABEL="ClosedSoftware 0.9b" URL="ClosedSoftware09b.exe" />

..<node LABEL="ClosedSoftware 0.4b" URL="ClosedSoftware04b.exe" />

.</node>

</node>

<node LABEL="Category 2"> and so on ...

This is the script so far. Please feel free to write it all over again, since the script is not doing what we're want it to do.

$doc = new DomDocument('1.0');

$root = $doc->createElement('root');

$root = $doc->appendChild($root);

$table_id = 'animal';

$query = "SELECT * FROM $table_id GROUP BY parentID";

$dbresult = mysql_query($query, $con);

while($row = mysql_fetch_assoc($dbresult)) {

$occ = $doc->createElement($table_id);

$occ = $root->appendChild($occ);

$subRoot = $doc->createElement('hehe');

$subRoot = $occ->appendChild($subRoot);

foreach ($row as $fieldname => $fieldvalue) {

$child = $doc->createElement($fieldname);

$child = $subRoot->appendChild($child);

$value = $doc->createElement($fieldvalue);

$value = $child->appendChild($value);

}

}

$xml_string = $doc->saveXML();

$file_handle = fopen('[url removed, login to view]','a');

fwrite($file_handle,$xml_string);

fclose($file_handle);

If there is any questions, don't hestitate to ask.

(This is our first posted project here. Hopefully there is good response, and if your good at this we'll probably hire you for further cooperation. Thank you.)

UPDATE: There is no need to place a "FILE" into more than 1 category. A file is only member of 1 category MAX.

Feel free to make the DB structure in another way.

Main thing is to output to the XML file correctly based on the hierarchy the file is under.

A "file" is always assigned to a category when created.

Skills: PHP, XML

See more: mysql label structure, occ doc createelement, to-do categories, re label, php free code, php description, no structure, group directory, code php free, c# category, php createelement mysql, good mysql category structure, hierarchy category structure mysql, mysql category structure, php node structure, what is node, node mysql, mysql free, free mysql, the php group, Structure, occ, need to put a label, mysql query, iso

About the Employer:
( 12 reviews ) 1169, Norway

Project ID: #240512

Awarded to:

astatine

I can do it for you very well and fast.

$30 USD in 1 day
(6 Reviews)
2.0