title: How can I create JSON structured data for search results in PHP?
body: <p>So, I have a music search engine here: <a href="http://zenek.neocsatblog.mblx.hu" rel="nofollow">http://zenek.neocsatblog.mblx.hu</a></p>
  
  <p>When you want to search something, the search URL looks like this:</p>
  
  <p><a href="http://zenek.neocsatblog.mblx.hu/search/love%20is%20gone%20david%20guetta" rel="nofollow">http://zenek.neocsatblog.mblx.hu/search/love%20is%20gone%20david%20guetta</a></p>
  
  <p>I want to provide structured data for every element on this page, with JSON and <code>script</code> tags. Unfortunately, this does not really work.</p>
  
  <p>I mean, I only get the first element of this page, but I doesn't get any loop. So, the HTML in this case looks like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script&gt;
  
  {
    "@context": "http://schema.org",
    "@type": "ImageObject",
    "author": "David Guetta - Love Is Gone...",
    "contentLocation": "Budapest, Hungary",
    "contentUrl": "http://i1.sndcdn.com/artworks-000112948246-z6q0y7-large.jpg",
    "description": "David Guetta - Love Is Gone...",
    "name": "David Guetta - Love Is Gone..."
        }
  &lt;/script&gt;
  </code></pre>
  
  <p>And my PHP code looks like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  $avatar = $GLOBALS['sys']-&gt;img($search-&gt;artwork_url, "100", $search-&gt;user-&gt;avatar_url); 
  $title =$GLOBALS["sys"]-&gt;sh_title(urldecode($search-&gt;title), "25"); 
  ?&gt;
  &lt;script&gt;
  &lt;?php echo '
  {
    "@context": "http://schema.org",
    "@type": "ImageObject",
    "author": "'.$title.'",
    "contentLocation": "Budapest, Hungary",
    "contentUrl": "'.$avatar.'",
    "description": "'.$title.'",
    "name": "'.$title.'"
        }
  '
  ?&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>What do I wrong?</p>