I'm trying to use a select input box to select data for a card by SQL. So I need to use the Input variable in the SQL query of the Card value.
I need to use the Dropdown Search bar value as a Where clause for the YearMonth clause that the Card value uses. How do I use a variable within an SQL statement?
Individual Card Creation Code
<?php
Card::create(array(
"dataSource"=>$this->dataStore("metrics"),
"value"=>$this->src("delv_kpi")->query("SELECT MetricValue FROM tbl_KPIMetrics where Client='DELV' and YearMonth=DATE_FORMAT(CURDATE(), '%y%m') and MetricID=1"),
"baseValue"=>$this->src("delv_kpi")->query("SELECT MetricValue FROM tbl_KPIMetrics where Client='DELV' and YearMonth=DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL -1 MONTH), '%y%m') and MetricID=1"),
"title"=>"New Clients Acquired",
"cssClass"=>array(
"card"=>"bg-info",
"title"=>"text-white",
"value"=>"text-white"
)
));
?>
Drop Down Creation code
<?php
//DropDown which lists Year/Months
Select2::create(array(
"name"=>"searchfor",
"dataStore"=>$this->dataStore("searchfor"),
"dataSource"=>$this->src("delv_kpi")->query("
Select Distinct YearMonth from tbl_kpimetrics "),
"dataBind"=>"YearMonth",
"attributes"=>array(
"class"=>"form-control",
)
));
?>