thellie
Member
Crack this and I'm ready to go live...
This is a checkbox element.
I want to pull in the names of the volunteers who would teach in a given lesson. The query pulls the names of those who are available (ie lesson date is between their start and finish dates).
But I can't get the query to pull in the variable - $lessondate. It works with a static date (ie '2019-02-02 00-00-00') so I know it's an issue with the variable $lessondate... but I've tried all the variations I can think of - long names, short names, (INT), _raw, new datetime(), etc etc...
At the moment I am using the second piece of code, which pulls the names of those currently onsite - it'll do but I'd prefer the first option if possible.
If I get this done, I can put the computer down for a while, to stop getting vertigo & vomiting from staring at the screen all day and night
This is a checkbox element.
I want to pull in the names of the volunteers who would teach in a given lesson. The query pulls the names of those who are available (ie lesson date is between their start and finish dates).
But I can't get the query to pull in the variable - $lessondate. It works with a static date (ie '2019-02-02 00-00-00') so I know it's an issue with the variable $lessondate... but I've tried all the variations I can think of - long names, short names, (INT), _raw, new datetime(), etc etc...
At the moment I am using the second piece of code, which pulls the names of those currently onsite - it'll do but I'd prefer the first option if possible.
If I get this done, I can put the computer down for a while, to stop getting vertigo & vomiting from staring at the screen all day and night
Code:
$mydb = FabrikWorker::getDbo();
$lessondate= '{lessonplans___lesson_date}';
$mydb->setQuery(
"SELECT user_id, CONCAT(first_name,' ',last_name) AS teacher FROM vol_appform
WHERE
((SELECT DISTINCT lesson_date FROM lessonplans WHERE lesson_date = '$lessondate') BETWEEN
startdate AND IF(actual_enddate,actual_enddate,enddate)) AND
(programme = 19 || programme = 20)
ORDER BY first_name
");
$rows = $mydb->loadObjectList();
foreach ($rows as $row) {
$options[] = JHTML::_('select.option', $row->user_id, $row->teacher);
}
return $options;
=========
$mydb = FabrikWorker::getDbo();
$lessondate= '{lessonplans___lesson_date}';
$mydb->setQuery(
"SELECT user_id, CONCAT(first_name,' ',last_name) AS teacher FROM vol_appform
WHERE
(CURDATE() BETWEEN
startdate AND IF(actual_enddate,actual_enddate,enddate)) AND
(programme = 19 || programme = 20)
ORDER BY first_name
");
$rows = $mydb->loadObjectList();
foreach ($rows as $row) {
$options[] = JHTML::_('select.option', $row->user_id, $row->teacher);
}
return $options;