How would I echo this XML data from a database using PHP simpleXML?

MsPeru

New Member
I am using a formbuilder plugin in Wordpress which submits the form input to the database as XML data. Now I would like to fetch that data and have it displayed in another page. I have started trying simpleXML to achieve this but now I have hit a road bump.The XML data that appears in each row of the database follows this format:\[code\]<form> <FormSubject>Report</FormSubject> <FormRecipient>****@***.com</FormRecipient> <Name>admin</Name> <Department>test</Department> <Value>1000</Value> <Comments>test</Comments> <Page>http://***.com</Page> <Referrer>http://****.com</Referrer></form>\[/code\]I have previously managed to fetch the data that I need using simpleXML from an XML string of the same markup which is in the database but now my question is, how do I do this with a loop for each row in the database?When the following code is run, wordpress displays a blank page meaning that there is an error:\[code\]<?phpglobal $wpdb;$statistics = $wpdb->get_results("SELECT * FROM wpformbuilder_results WHERE form_id = '00000000000000000001';");echo "<table>";foreach($statistics as $statistic){$string = $statistic->xmldata$xml = simplexml_load_string($string);$Name = (string) $xml->Name;$Department = (string) $xml->Department;$Value = http://stackoverflow.com/questions/14544101/(string) $xml->Value;$Comments = (string) $xml->Comments;echo"<tr>";echo "<td>".$statistic->timestamp."</td>";echo "<td>".$Name."</td>";echo "<td>".$Department."</td>";echo "<td>".$Value."</td>";echo "<td>".$Comments."</td>";echo "</tr>";}echo "</table>";?>\[/code\]
 
Back
Top