-1

I have a evocalendar that i want to use php to make the calendar dynamic

<script>
    $(document).ready(function() {
    $('#calendar').evoCalendar({

        
        calendarEvents: [

        {
        id: '1', // Event's ID (required)
        name: "Finding The Person Called Me", // Event name (required)
        date: "January/1/2020", // Event date (required)
        description:"test event of finding the person called me",
        type: "Public Meeting", // Event type (required)
        everyYear: false // Same event every year (optional)
      }
  ]
  });

When it like this the jquery works, javascript works.But when i add php like the code below, then works. What is the cause?

    <?php
       <script>
        $(document).ready(function() {
        $('#calendar').evoCalendar({
    
            
            calendarEvents: [
    
            {
            id: '1', // Event's ID (required)
            name: "Finding The Person Called Me", // Event name (required)
            date: "January/1/2020", // Event date (required)
            description:"test event of finding the person called me",
            type: "Public Meeting", // Event type (required)
            everyYear: false // Same event every year (optional)
          }
    $query = "SELECT * FROM calendar";
//GET RESULT
    $result = $pdo->query($query);
    $result->setFetchMode(PDO::FETCH_ASSOC);
    while($row = $result->fetch()){
       echo '{';
       echo 'id:'.'"'.rand(100,1000).'",';
       echo 'name:'.'"'.$row['eventname'].'"'.',';
        echo 'date:'.'["'.$row['eventdate'].'"],';
        echo 'color:'.'"#00aba9"';
        echo'},';
    }
?>
    ]
  });

It doesn't work.

J. Roberts
  • 11
  • 5
  • 2
    Looks like you have your JavaScript code right in the middle of your PHP code; that's not correct. – Pointy Aug 12 '23 at 11:18
  • 1
    "_It doesn't work._" doesn't help a lot. Do you get a blank page? Any php errors? Any JS errors in your browser console? – brombeer Aug 12 '23 at 11:22
  • I am getting this error in the console "Uncaught TypeError: e is undefined" – J. Roberts Aug 12 '23 at 11:26
  • Turn on error_reporting for PHP ([How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display?rq=1)) so you'll see the "_Parse error: syntax error, unexpected token "<" ..._" – brombeer Aug 12 '23 at 11:35
  • [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – RiggsFolly Aug 12 '23 at 13:32

0 Answers0