MY_Xml_Writer - Easy XML writer library |
[eluser]JoostV[/eluser]
It might be easier if you could solve this problem in you SQL; Code: $sql = 'SELECT COUNT(function) as num_fonctions, fonction FROM tablename GROUP BY fonction'; Then all you'd have to do is create a loop like this: Code: $corr = array('Graphist', 'AD', 'Art Director');
[eluser]Shimura[/eluser]
Same problem :/ One node for one result not a total result. I have my colums num_fonctions (1,1,1,1,1) in PHPmyAdmin and in my xml : <Projet_Graph>1</Projet_Graph> <Projet_Graph>1</Projet_Graph> How i make a total of that ?
[eluser]JoostV[/eluser]
Hi Shimura, I really need some more info. What exactly is in your table and what exactly are you trying to display?
[eluser]Shimura[/eluser]
In my table equipes, i have id, fonction(Name of job in a project), id_etudiant, id_projet. The result of SQL in PHPmyadmin is : [num_functions] [fonction] [id_etudiant] 1 Graphist 200 1 AD 139 And when i'm in the result of the foreach ($correspondance_graph as $corr) , that's recover the count yes. But with the foreach, the xml display : One result for a node, like this : <projet_graph>1</projet_graph> <projet_graph>1</projet_graph> And i'm trying to display this for one student : <projet_graph>2</projet_graph> The problems comes that when my foreach find a correspondence, he displays one node : <projet_graph>1</projet_graph> Thank you.
[eluser]JoostV[/eluser]
OK, so now I know what is in your table. Code: $equipes->id; I am still having a hard time understanding what exactly you WANT to display in the XML. Do you want to display all functions for a single student? Or all students that take part in a project? Show me an example XML, please. I cannot help you if I don't know what the problme is.
[eluser]Shimura[/eluser]
This is an example of XML TEST : Code: <Etudiant Promotion="2010" Nb_id="224"> You see the problem : Code: <Fonction_Projet>Designer</Fonction_Projet> And i want : Code: <Fonction_Projet>Designer</Fonction_Projet> I recover on result 1 for one node. But me i want a total result for one node.
[eluser]Shimura[/eluser]
And this is an example of one student only, i have about 40 students for a promotion.
[eluser]JoostV[/eluser]
First off, you might want to reconsider teh XML you're creating. - all XML is lowercase - Nest your tags. - you might want to use the same tag for all functions, so <function id="graph">, instead of using a different tag for each function Anyway. First retrieve all functions for all students, and store them in an array with the student id as key Code: /*Fetch all functions for all students*/ Then, for the <Projet> branch, you create a loop for a certain student like this (let's pretend that the ID for that student is available in $id_etudiant) Code: /*Add all functions for this student*/ This will give you a clean piece of properly nested XML without any repetitions, like this: Code: <projet> I'm sure you can figure out any modifications yourself. Hope to have been of help here. EDIT: alternatively, you could also construct an XML like: Code: <projet>
[eluser]Unknown[/eluser]
how i can generate it to .xml file (sory i not good english)
[eluser]JoostV[/eluser]
Just grab the data and save it to a file, for instance using the file helper: http://ellislab.com/codeigniter/user-gui...elper.html |
Welcome Guest, Not a member yet? Register Sign In |