title: PHP echo button onclick function
body: <p>For a little "webshop project" I create a table with PHP and echo"..." function. The table displays some values and in the last cells, there shall be a button which enables the user to delete the corresponding row (or better said, purchase). The data is held in a database and read out while the page loads and than displayed in the table.</p>
  
  <p>I use a "purchase id" to find out which rows have to be deleted, and it works fine if I just implement the function itself. The problem is that I can't get the function working as "onclick" event for the button.</p>
  
  <p>So, some code:</p>
  
  <pre><code>function delete_purchase($purchase_id){
  mysql_query("DELETE FROM purchase WHERE purch_id = '$purchase_id'");};
  </code></pre>
  
  <p>That's the PHP function which deletes the rows, easy enough.</p>
  
  <pre><code>$result = mysql_query("SELECT purchase.purch_id, item.name, purchase.amount, purchase.purch_date, delivery.meaning, item.weight FROM purchase, item, delivery WHERE purchase.cust_id='$cust_id' AND delivery.del_id = purchase.delivered AND purchase.item_id = item.item_id");
  
  while($row = mysql_fetch_array($result))
      {
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['amount'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['weight'] * $row['amount'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['purch_date'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['meaning'] . "&lt;/td&gt;";
      echo "&lt;td&gt;&lt;button onclick=\"delete_purchase('" . $row['purch_id'] . "')\"&gt;Kill&lt;/button&gt;&lt;/td&gt;";
      echo "&lt;/tr&gt;";
      }
  </code></pre>
  
  <p>And this is the part which doesn't seem to work. I get the variable and some other values from the database and insert them into my table as long as there are values. Everything is displayed, even the buttons; but clicking on them doesn't do anything. </p>
  
  <p>Source code of the website seems fine:</p>
  
  <pre><code>&lt;td&gt;&lt;button onclick="delete_purchase('138')"&gt;Kill&lt;/button&gt;&lt;/td&gt;
  </code></pre>
  
  <p>Hope everything's clear, and you guys have some ideas what's wrong. If you need to know additional stuff, just ask and I'll see what I can do.</p>