title: Is it possible to insert php variables into your js code?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7141860/passing-variables-from-php-to-javascript">passing variables from php to javascript</a>  </p>
  </blockquote>
  
  
  
  <p>I'm dynamically generating a list. I want to make each row hover on mouseover and clickable to a link. I want the link to pass the id of the content of the row. </p>
  
  <p>Basically: </p>
  
  <pre><code>foreach ($courses as $cid=&gt;cinfo){ 
    $univ = $cinfo['univ'];
    $desc = $cinfo['desc'];
    $size = $cinfo['size'];
    $start = $cinfo['start'];
    print "&lt;div class='rc_desc' id='rc_desc$cid'&gt;"."$desc&lt;br/&gt;"."&lt;b&gt;$univ&lt;/b&gt;&lt;br/&gt;".
          "&lt;span&gt;Number of students&lt;/span&gt;: $size&lt;br/&gt;".
          "&lt;span&gt;Started at&lt;/span&gt;: ".date('F d, Y',strtotime($start))."&lt;br/&gt;".
  }
  
  &lt;script&gt;
      $(function ()
      {
        $('#rc_desc$cid').hover(function ()
        {
          $(this).toggleClass('.tr');
        });
        $('#rc_desc$cid').click(function ()
        {
          $(location).attr('href','student.php?$cid');
        });
      });
    &lt;/script&gt;
  </code></pre>
  
  <p>The issue is in the js/jquery. I want to be able to grab the $cid and pass it to the student.php page upon click. The php code above works but the js won't of course. I know the fundamental of client-side vs server-side languages. This question doesn't warrant a lecture. I know I cannot do this exactly, but it is what I want to happen ultimately. Any thoughts on how I can achieve this simply? Thanks in advance my friends!</p>