title: How do i add onclick function to my php code using html and echo
body: <p>so i have this code i wrote and i want to add an onclick to the img, the problem is that when i add an onclick i need to use semi colons and the echo ends, how do i do that?</p>
  <p>php:</p>
  <pre><code>echo '&lt;div id=&quot;cloth&quot;&gt; &lt;img src=&quot;' . $row[&quot;Image_url&quot;] . '&quot; width=&quot;300&quot; height=&quot;400&quot; alt=&quot;' . $row[&quot;Name&quot;] . '&quot; style=&quot;margin: 15px;&quot; id=&quot;' . $row[&quot;Name&quot;] . '&quot;&gt;&lt;/div&gt;';
  </code></pre>
  <p>what i want to add:</p>
  <pre><code>onclick=&quot;product('&quot; . $row[&quot;name&quot;] . &quot;')&quot;
  </code></pre>
  <p>i want it to look like that:</p>
  <pre><code>echo '&lt;div id=&quot;cloth&quot;&gt; &lt;img src=&quot;' . $row[&quot;Image_url&quot;] . '&quot; width=&quot;300&quot; height=&quot;400&quot; alt=&quot;' . $row[&quot;Name&quot;] . '&quot; style=&quot;margin: 15px;&quot; id=&quot;' . $row[&quot;Name&quot;] . '&quot; onclick =&quot;product(&quot;' . $row[&quot;Name&quot;] . '&quot;)&quot;&gt;&lt;/div&gt;'; 
  </code></pre>
  <p>js product function:</p>
  <pre><code>function product(id) {
      var title = document.getElementById(id);
      sessionStorage.setItem(&quot;title&quot;, id);
      window.location.replace(&quot;product.php&quot;);
  }
  </code></pre>