Hi guys,
I have statistic page on my website which I want to optimize.I’m just make it that work’s,but it’s not good and I know it.
I need to have all statistic information in an array.This is example:
I need to count for all “teams” how much they have “zones”.And after it set values on $data_chart6 (Keep on mind that I don’t use all Team ID… I don’t use ID 1,6,8,12,13 )
$mm = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘2’”);
$bdt = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘3’”);
$gsf = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘4’”);
$bal = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘5’”);
$lcn = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘7’”);
$rm = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘9’”);
$be = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘10’”);
$lms = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘11’”);
$tem = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘14’”);
$yak = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘15’”);
$gdf = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘16’”);
$bc = $Db->getRow(“SELECT COUNT(ID) AS total FROM zone Where Team = ‘17’”);
$data_chart6[0] = $mm[‘total’];
$data_chart6[1] = $bdt[‘total’];
$data_chart6[2] = $gsf[‘total’];
$data_chart6[3] = $bal[‘total’];
$data_chart6[4] = $lcn[‘total’];
$data_chart6[5] = $rm[‘total’];
$data_chart6[6] = $be[‘total’];
$data_chart6[7] = $lms[‘total’];
$data_chart6[8] = $tem[‘total’];
$data_chart6[9] = $yak[‘total’];
$data_chart6[10] = $gdf[‘total’];
$data_chart6[11] = $bc[‘total’];
How I can make this better?Thanks
GetRow and GetList function which I use(Here I use just GetRow)
public function getRow($sql = '')
{
if ($sql) {
if (!$this->execute($sql)) {
return false;
}
}
$row = null;
if ($this->_resc) {
$row = mysql_fetch_assoc($this->_resc);
}
return $row;
}
public function getList($sql = '', $type = 'arr')
{
if ($sql) {
if (!$this->execute($sql)) {
return false;
}
}
$rows = null;
if ($this->_resc) {
while ($row = ($type == 'obj') ? mysql_fetch_object($this->_resc) : mysql_fetch_array($this->_resc)) {
$rows[] = $row;
}
}
return $rows;
}