How to use jQuery within PHP
<p>I'm using a php tree browser that I got from <a href="http://www.lateralcode.com/directory-trees-with-php-and-jquery/" rel="nofollow">http://www.lateralcode.com/directory-trees-with-php-and-jquery/</a></p>

<pre><code>&lt;?php
 $path = ".";

 function createDir($path = '/')
 { 
  if ($handle = opendir($path)) 
  {
   echo "&lt;ul&gt;";

   while (false !== ($file = readdir($handle))) 
   {
    if (is_dir($path.$file) &amp;&amp; $file != '.' &amp;&amp; $file !='..')
     printSubDir($file, $path, $queue);
    else if ($file != '.' &amp;&amp; $file !='..')
     $queue[] = $file;
   }

   printQueue($queue, $path);
   echo "&lt;/ul&gt;";
  }
 }

 function printQueue($queue, $path)
 {
  foreach ($queue as $file) 
  {
   printFile($file, $path);
  } 
 }

 function printFile($file, $path)
 { 
  echo "&lt;li&gt;&lt;a style=\"cursor:pointer\" ".
       "onClick=\"parent.right.document.getElementById('file_path').value='".
       "$file_path'\"&gt;$file_path&lt;/a&gt;&lt;/li&gt;";
 }

 function printSubDir($dir, $path)
 {
  echo "&lt;li&gt;&lt;span class=\"toggle\"&gt;$dir&lt;/span&gt;";
  createDir($path.$dir."/");

 ?&gt;

 **&lt;script language="javascript"&gt;
   $(document).click(function(e) { 
   if (e.button == 0) {
    // was the left button
    alert('clicked'); 
   }
  });
  &lt;/script&gt;**

 &lt;?php 
  echo "&lt;/li&gt;";
</code></pre>

<p>However, I want to detect a right-click that is pressed inbetween, so that I can trigger an event. However, I can't seem to get the jquery code to work within my PHP. The reason being, that I don't get an alert popup when I execute the code ... Ideally, I want to have this included within my php code, since I need to use my php <code>variable $file_path</code></p>
