1
Hello! I want to retrieve the events from the database and display them in the calendar. Can you help me to do this? So far I have the following codes:
Model:
Public function obter_noticias()
{
$sql = "SELECT * FROM noticias WHERE noticias.id";
return $this->db->query($sql, array($_GET['start'], $_GET['end']))->result();
}
controller
Public function obter_noticias()
{
$result=$this->Noticias_model->obter_noticias();
echo json_encode($result);
echo $this->db->last_query();
die();
}
In the.js file, I am using the following code
var base_url='http://localhost/ci_adminlte/admin';
$(document).ready(function(){
$('#calendar').fullCalendar({
//alert('Teste de carregamento FullCalendar');
header: {
left: 'prev,next today',
center: 'title',
//right: 'month,basicWeek,basicDay'
right: 'month,agendaWeek,agendaDay,listWeek,'
},
editable: false,
navLinks: true,
//selectable: true,
selectHelper: true,
events: base_url+'noticias/obter_noticias'
});
});
Below, follow my table
id INT(11) NOT NULL AUTO_INCREMENT,
data DATETIME NOT NULL,
titulo TEXT NULL DEFAULT NULL,
noticia TEXT NULL DEFAULT NULL,
usuario_cadastro VARCHAR(40) NOT NULL,
usuario_alteracao VARCHAR(40) NOT NULL,
dt_cadastro DATETIME NOT NULL,
dt_alteracao DATETIME NULL DEFAULT NULL,
Why
echo $this->db->last_query();
?– ShutUpMagda
To test the queries.
– Wagner Fillio
And how about the answer to
JavaScript
? Truncated?– ShutUpMagda
Truncated, yes!!
– Wagner Fillio
But then it won’t work anyway, champ.
– ShutUpMagda
But every function that renders the fullcalendar is in this file. So I believe Events also has to be in this code.
– Wagner Fillio
What’s it like? The function that renders the
fullcalendar
is in thecontroller
? This is not correct. Thecontroller
should only return the objectjson
. The libraryfullcalendar
will only use the object generated bycontroller
in hisevents
.– ShutUpMagda
It is not in the controller, It is in a file . js, called through the view.
– Wagner Fillio
And where is the
VIEW
? You could save this object in a variable and pass toVIEW
click onJavaScript
. Have you tried that?– ShutUpMagda
I tried, The way I have in the example above, I put some Events manually and so it appears, but when I try to popular through the database, I can’t
– Wagner Fillio