Note that there are some explanatory texts on larger screens.

plurals
  1. POloading from an XML file into PHP to generate content
    primarykey
    data
    text
    <p>So what I am trying to do is load data from an XML file into php and use those variables to generate content. For each item i want to get a new set of variable values and print them out onto the page. If there are 4 interfaceItems then it should print 4 displayWrappers with 4 unique titles. This isn't working for me. Is there a better or more efficient way of doing this? The errors I am getting right now are:</p> <p>Notice: Trying to get property of non-object</p> <p>Warning: Invalid argument supplied for foreach()</p> <pre><code>&lt;?php $xmldata = simplexml_load_file('elements.xml'); foreach($xmldata-&gt;portfolio-&gt;interface-&gt;interfaceItem as $item) :?&gt; &lt;?php $title = ($item-&gt;title); $desc = ($item-&gt;description); $whatOne = ($item-&gt;whatOne); $whatTwo = ($item-&gt;whatTwo); $location = ($item-&gt;location); ?&gt; &lt;div class="displayWrapper"&gt; &lt;div class="display"&gt; &lt;p&gt; &lt;?=$title ?&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php endforeach;?&gt; &lt;portfolio&gt; &lt;interface&gt; &lt;interfaceItem&gt; &lt;title&gt;modi tempora&lt;/title&gt; &lt;decription&gt;lorum ipsum&lt;/decription&gt; &lt;whatOne&gt; dolor sit amet&lt;/whatOne&gt; &lt;whatTwo&gt;sed quia non&lt;/whatTwo&gt; &lt;location&gt;i/blah.jpg&lt;/location&gt; &lt;/interfaceItem&gt; &lt;interfaceItem&gt; &lt;title&gt;magnam aliquam&lt;/title&gt; &lt;decription&gt;omnis voluptas assumenda est, omnis dolor repellendus.&lt;/decription&gt; &lt;whatOne&gt;expedita distinctio&lt;/whatOne&gt; &lt;whatTwo&gt;possimus, omnis voluptas&lt;/whatTwo&gt; &lt;location&gt;i/blah2.jpg&lt;/location&gt; &lt;/interfaceItem&gt; &lt;/interface&gt; &lt;/portfolio&gt; </code></pre>
    singulars
    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