Pass a PHP array to a Jquery file
<p>I'm working on a calendar where events are called from a database and shown. The results then are links and I want to be able to click on them and it opens a frame to a page "viewevent.php?id=$id". It opens nice as a frame, but no matter what I do I cannot get it to work because the frame only opens the last id in the database. I used the jquery plugin Simple Modal, but I modified it some bit. My source codes are below.</p>

<p>Jquery file (osx.js):</p>

<pre><code>jQuery(function ($) {
var OSX = {
    container: null,
    init: function () {
        $("input.osx, a.osx").click(function (e) {
            e.preventDefault(); 
// Display an external page using an iframe
var id = eventid;
var src = "viewevent.php?id="+ id +"";
$.modal('&lt;iframe src="' + src + '" height="450" width="830" style="border:0"&gt;', {
closeHTML:"",
containerCss:{
    backgroundColor:"#fff", 
    borderColor:"#fff", 
    height:450, 
    padding:0, 
    width:830
},
overlayClose:true
});`
</code></pre>

<p>Calendar file (calendar.php):</p>

<pre><code>  /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/
        $todaydate = $year.'-'.$month.'-'.$x;
$query = "SELECT * FROM `events` WHERE '$todaydate' &gt;= event_start AND '$todaydate' &lt;= event_end";
$results = mysql_query($query) or die (mysql_error());
        if (mysql_num_rows($results) &gt; '0') {
          while($row = mysql_fetch_array($results)){ 
          extract($row);   
          $calendar.= '&lt;!-- modal content --&gt;
    &lt;div align="center" id="osx-modal-content"&gt;
        &lt;div id="osx-modal-title"&gt;View Event&lt;/div&gt;
        &lt;div class="close"&gt;&lt;a href="#" class="simplemodal-close"&gt;x&lt;/a&gt;&lt;/div&gt;
        &lt;div id="osx-modal-data"&gt;
            &lt;h2&gt;The id for this page is '.$id.'&lt;/h2&gt;
            &lt;p&gt;Blah blah testing and junk. It only shows data from last insert.&lt;/p&gt;
            &lt;iframe align="middle" scrolling="no" frameborder="0" src="viewevent.php?id='.$id.'"&gt; &lt;/iframe&gt;
            &lt;p&gt;&lt;button class="simplemodal-close"&gt;Close&lt;/button&gt; &lt;span&gt;(or press ESC or click the overlay)&lt;/span&gt;&lt;/p&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;';   
   $catquery = "SELECT * FROM categories WHERE id=$catid";
   $catres = mysql_query($catquery) or die (mysql_error());
   $catrow = mysql_fetch_array($catres);
   $cat = $catrow['color'];
 $calendar.= '&lt;div style="margin-top:2px; height:10px; width:10px; float:left; background:'.$cat.'"&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="calendar-text"&gt;&lt;a href="viewevent.php?id='.$id.'" class="osx"&gt;'.$class.' - '.$title.'&lt;/a&gt;&lt;/div&gt;';
?&gt;
     &lt;script type="text/javascript"&gt;
var eventid = '&lt;?php echo $id; ?&gt;'

&lt;/script&gt;
&lt;?
  /* $catquery = "SELECT * FROM categories WHERE id=$catid";
   $catres = mysql_query($catquery) or die (mysql_error());
   $catrow = mysql_fetch_array($catres);
   $cat = $catrow['name'];
  $calendar.= '&lt;div class="'.$cat.'"&gt;&amp;nbsp;&lt;/div&gt;&lt;div class="calendar-text"&gt;&lt;a href="viewevent?id='.$id.'"&gt;'.$event.'&lt;/a&gt;&lt;/div&gt;';
 */
  //end while  
  }
</code></pre>

<p>and here is a live view of my site showing the problem:
<a href="http://my.iheff.net/webbook/test.php" rel="nofollow">http://my.iheff.net/webbook/test.php</a></p>

<p>I appreciate any help in the right direction, thank you!</p>
