Send id by URL to full Legend

Asked

Viewed 256 times

3

I use Full Calendar to display an agenda on my system, but I’m not able to send a id through the url of the file that mounts the json with the dates, and need this to filter the events that are linked only to this id. Follow 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>

php events.

$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 anyone knows how I can do it, I’d appreciate it!

  • And what is the value of id which is passed this way?

  • That question I already solved, I will post the answer today if possible.

1 answer

0


Some details have been adjusted. Below is the resolution:

php events.

<?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);

php agenda.

<?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> 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.