Send id by URL to full calendar

3

I use Full Calendar to display a calendar on my system, but I am not able to send a id through the url of the file that json mounts with the dates, and I need to filter the events that are only bound to this id . Here is my code below:

Calendar page:

    <script>
        var id       = '<?php echo '<a href="eventos?id=' . $id . '">'?>'
            $(document).ready(function() {  

                    //CARREGA CALENDÁRIO E EVENTOS DO BANCO
                    $('#calendario').fullCalendar({
                        header: {
                            left: 'prev,next',
                            center: 'title',
                            right: 'month,agendaWeek,agendaDay'
                        },
                        editable: true,
                        eventLimit: true, 
                        events: 'eventos.php',          
                        eventColor: '#0277BD'
                    }); 
            }); 

            </script>
<section class="panel">
                         <header class="panelheading" id="locado">
                                Agenda
                            </header>
                           <div class="panel-body" id="panel">
                                <div class="panel-body table-responsive">
                                    <div class="page">
                                        <div id='calendario'>
                                        </div>
                                    </div>                                                                                            
                                </div>
                            </div>
                    </section>

events.php

$id = $_GET['id'];
$consulta = $conexao->query("SELECT id, title, start, ADDDATE(end, INTERVAL 1 DAY) as end FROM calendario where id = '$id'");
    while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) { 
        $vetor[] = $linha;      
    }
    echo json_encode($vetor);

If someone knows how I can do it, thank you!

    
asked by anonymous 27.05.2017 / 03:39

1 answer

0

Some details have been adjusted. Here is the resolution:

events.php

<?php
$id = $_GET['id'];
$consulta = $conexao->query("SELECT id, title, start, ADDDATE(end, INTERVAL 1 DAY) as end FROM registros where pan_id = '$id'");
    while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) { 
        $vetor[] = $linha;   
    }
echo json_encode($vetor);

agenda.php

<?php
  $id = $_GET['id'];
  $result = mysqli_query($conexao, "SELECT * FROM registros WHERE id = '$id'");
    while($exibe = mysqli_fetch_array($result)){?>
      <input type="hidden" name="id" id="id" value="<?php echo $exibe['id']?>"/>
    <?php }?>
        <script>
        var id = document.getElementById('id').value;
                    $(document).ready(function() {  

                    $('#calendario').fullCalendar({
                        header: {
                            left: 'today, prev,next',
                            center: 'title',
                            right: 'month,agendaWeek,agendaDay'
                        },
                        editable: true,
                        eventLimit: true, 
                        events: 'eventos.php?id='+id,          
                        eventColor: '#0277BD'
                    }); 
            }); 

            </script> 
    
13.06.2017 / 22:30