Note that there are some explanatory texts on larger screens.

plurals
  1. POLoop for only one category XML-PHP
    primarykey
    data
    text
    <p>I have an XML file and i want to read data with PHP. I had read data from it but the problem is that i only want to run loop for one category and show all matches in this category Here is my XML <a href="http://www.goalserve.com/samples/soccer_livescore.xml" rel="nofollow">File link</a> And My PHP code </p> <pre><code>&lt;?php $test = simplexml_load_file('http://www.goalserve.com/samples/soccer_livescore.xml'); //echo $test-&gt;category-&gt;matches-&gt;match-&gt;localteam["name"]."&lt;br&gt;"; //echo $test-&gt;category-&gt;matches["date"]; ?&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;td style="border:none;"&gt;Local Team &lt;/td&gt; &lt;td&gt;Score &lt;/td&gt; &lt;td&gt;Visitor team&lt;/td&gt; &lt;td&gt;Status &lt;/td&gt; &lt;td&gt;Date &lt;/td&gt; &lt;td&gt;Time &lt;/td&gt; &lt;td&gt;HT &lt;/td&gt; &lt;td class="hidden-result"&gt;Events&lt;/td&gt; &lt;/tr&gt; &lt;?php foreach ($test-&gt;category as $cate) { foreach ($cate-&gt;children() as $matches) { foreach ($matches-&gt;children() as $match) { // print_r($match); echo "&lt;td&gt;".$match-&gt;localteam["name"]."&lt;/td&gt;"; echo '&lt;td&gt;&lt;a href="javascript:MoreInformation('.$match["fix_id"].');"&gt;&lt;img src="http://www.goalserve.com/images/arrow-down.gif" alt="More information" title="More information" id=I'.$match["fix_id"].'" name=I'.$match["fix_id"].' /&gt;'.$match-&gt;localteam["goals"].'-'.$match-&gt;visitorteam["goals"].'&lt;/a&gt;&lt;/td&gt;'; echo "&lt;td&gt;".$match-&gt;visitorteam["name"]."&lt;/td&gt;"; echo "&lt;td&gt;".$match["status"]."&lt;/td&gt;"; echo "&lt;td&gt;".$match["date"]."&lt;/td&gt;"; echo "&lt;td&gt;".$match["time"]."&lt;/td&gt;"; echo "&lt;td&gt;".$match-&gt;ht["score"]."&lt;/td&gt;"; ?&gt; &lt;div class="hidden-result"&gt; &lt;?php foreach ($match-&gt;events-&gt;event as $t_event) { if($t_event["type"]=="goal") { ?&gt; &lt;td class="hidden-result" id="&lt;?php echo "R".$match["fix_id"]?&gt;" name="&lt;?php echo "R".$match["fix_id"]?&gt;"&gt;&lt;img src='images/1.gif' alt=""&gt;&lt;?php echo $t_event["player"]."(".$t_event["team"].")" ?&gt;&lt;/td&gt; &lt;?php } if($t_event["type"]=="yellowcard") {?&gt; &lt;td class="hidden-result" id="&lt;?php echo "R".$match["fix_id"]?&gt;" name="&lt;?php echo "R".$match["fix_id"]?&gt;"&gt;&lt;img src='images/3.gif' alt=""&gt;&lt;?php echo $t_event["player"]."(".$t_event["team"].")" ?&gt;&lt;/td&gt; &lt;?php } if($t_event["type"]=="redcard") {?&gt; &lt;td class="hidden-result" id="&lt;?php echo "R".$match["fix_id"]?&gt;" name="&lt;?php echo "R".$match["fix_id"]?&gt;"&gt;&lt;img src='images/2.gif' alt=""&gt;&lt;?php echo $t_event["player"]."(".$t_event["team"].")" ?&gt;&lt;/td&gt; &lt;?php } }?&gt; &lt;/div&gt; &lt;?php echo "&lt;/tr&gt;"; } } } ?&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload