I'm trying to get the URL parameter value to the php class and use it WHERE clause in the SQL query.
I have read [GET URL parameter in PHP] and it's helpful but doesn't address Whatever I want. I want to get it inside the PHP class.I read all similar questions in StackOverflow regarding this
Here is the PHP code.
Example URL = https://wacoal/home.php?mo=07 Simply I want to get the above URL mo value to the php class and use it in SQL query
<?php
namespace Phppot;
class Student
{
private $dbConn;
public function __construct()
{
require_once __DIR__ . '/DataSource.php';
$this->dbConn = new DataSource();
}
function getStudentMark()
{
$mo = $_GET['mo'];
//$query = "SELECT machine_type AS `type`,
SUM(CASE WHEN `line` = '1' THEN 1 ELSE 0 END) AS `Line 1`,
SUM(CASE WHEN `line` = '2' THEN 1 ELSE 0 END) AS `Line 2`,
SUM(CASE WHEN `line` = '3' THEN 1 ELSE 0 END) AS `Line 3`,
SUM(CASE WHEN `line` = '4' THEN 1 ELSE 0 END) AS `Line 4`,
SUM(CASE WHEN `line` = '5' THEN 1 ELSE 0 END) AS `Line 5`,
SUM(CASE WHEN `line` = '6' THEN 1 ELSE 0 END) AS `Line 6`,
SUM(CASE WHEN `line` = '7' THEN 1 ELSE 0 END) AS `Line 7`,
SUM(CASE WHEN `line` = '8' THEN 1 ELSE 0 END) AS `Line 8`,
SUM(CASE WHEN `line` = '9' THEN 1 ELSE 0 END) AS `Line 9`,
SUM(CASE WHEN `line` = '10' THEN 1 ELSE 0 END) AS `Line 10`
FROM dr_scan
WHERE MONTH(date)='" . $mo . "'
GROUP BY machine_type
";
$result = $this->dbConn->select($query);
return $result;
}
I tried it by adding another constrcutor but it gives an error "Cannot redeclare method"