Create table in php using xml data

Revis

New Member
I need to create results table column into row. If I choose 5 meeans it will show 5 results in row.\[code\]<?php$string = '<?xml version="1.0" encoding="utf-8"?><books><book isbn="978-1594489501"><title>book Title 1</title><author>Author 1</author><publisher>publisher 1</publisher><price>price 1</price><genre>English 1</genre></book><book isbn="978-1594489502"><title>book Title 2</title><author>Author 2</author><publisher>publisher 2</publisher><price>price 2</price><genre>English 2</genre></book></books>';$xml = new SimpleXMLElement($string);$string = 'book';$result = $xml->xpath("//book[contains(translate(title,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), '".strtoupper($string)."')]"); foreach($result as $one){echo "<table border='1' width='500'>\n";echo "<tr><th>Title</th><td>$one->title</td></tr>\n";echo "<tr><th>Author</th><td>$one->author</td></tr>\n";echo "<tr><th>Publisher</th><td>$one->publisher</td></tr>\n";echo "<tr><th>Price</th><td>$one->price</td></tr>\n";echo "<tr><th>Genre</th><td>$one->genre</td></tr>\n";echo "</table>\n"; }?>\[/code\]
 
Back
Top