title: Using JavaScript inside PHP code
body: <p>Ok so I have a booking system that I am working on and I have events created in a table which gets populated by PHP if the admin adds new events. I would like to run a script if the user tries to book an event and then submit the form to php. I would like to do this because I want to know if the user has a voucher and wants to pay either by card or via paypal.</p>
  
  <p>Here is the table screenshot, sorry only a link I need 10 rep points.</p>
  
  <p><img src="https://i.stack.imgur.com/ySTIs.jpg" alt="http://thomasniven.com/table.jpg"></p>
  
  <p>The PHP code that creates the tables:</p>
  
  <pre><code>&lt;?php
  $con = mysql_connect("localhost","root","");
  
  if(!$con)
  {
      die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db("flexiflash", $con);
   echo "&lt;thead&gt;";
   echo "&lt;tr&gt;";
   echo "&lt;th&gt;ID&lt;/th&gt;";
   echo "&lt;th&gt;Venue&lt;/th&gt;";
   echo "&lt;th&gt;Event&lt;/th&gt;";
   echo "&lt;th&gt;Date&lt;/th&gt;";
   echo "&lt;th&gt;Time&lt;/th&gt;";
   echo "&lt;th&gt;&lt;/th&gt;";
   echo "&lt;/tr&gt;";
   echo "&lt;/thead&gt;";
  
  $result = mysql_query("SELECT * FROM events");
  
  while($row = mysql_fetch_array($result))
  {
      echo "&lt;tbody&gt;";
      echo "&lt;form class='table-form'  action='book_event.php' method='post' onsubmit='return check()'&gt;";
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;" . $row['Event_ID'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['Event_Venue'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['Event_Name'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['Event_Date'] . "&lt;/td&gt;";
      echo "&lt;td&gt;" . $row['Event_Time'] . "&lt;/td&gt;";
      echo "&lt;td&gt;&lt;input type='submit' class='sub_btn' name='submit' value='Book now'&gt;&lt;/td&gt;";
      echo "&lt;/tr&gt;";
      echo "&lt;/form&gt;";
      echo "&lt;/tbody&gt;";
  }
  
  mysql_close($con);
  ?&gt;
  </code></pre>
  
  <p><strong>IF YOU NEED ANY MORE INFO LET ME KNOW</strong></p>