在php文件中的fullcalendar,javascript和php

I am trying to use the jQuery fullcalendar and I must set events dynamically from queries.

I must use PHP and JavaScript together for getting and setting events in the calendar.

My code doesn't work:

<?php
    $query = "SELECT * FROM visita_pre"; // query
    $res = mysql_query($query);          // salvataggio risultato query
    if ($res && mysql_num_rows($res) > 0) {                            
        // se la query ha dato risultato<?php
        while ($row = mysql_fetch_assoc($res)) {                         
        // ciclo scansione righe risultato query
            if ($row['id'] !== null) {
                $tipo = $row['tipo'];
                $start= $row['start'];
                $end = $row['end'];
                $cell = $row['cell'];
?>
<script>
    var event = {title: 'New event', start: <?php print $start; ?>};
    $('#calendar').fullCalendar('renderEvent', event, true);
</script>
<?php
}
}
}
?>

It doesn't generate outputs and the console tells me that I have 4 syntax errors:

  • 1 Unexpected end of input, and
  • 2 Unexpected identifier, and
  • 1 Unexpected token.