Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Mysql连接的表不应该是';不能加入_Php_Mysql - Fatal编程技术网

Php Mysql连接的表不应该是';不能加入

Php Mysql连接的表不应该是';不能加入,php,mysql,Php,Mysql,我的代码中出现了一个问题,但是当我在phpmyadmin中测试查询时,我得到了NULL(就像它应该的那样) 我想连接两个表以显示有关用户的所有信息。用户表包含有关客户端的基本信息。在我的页面上,我想添加关于用户可能的医生访问、物理治疗师访问和专家治疗的信息。每个连接都存储在不同的表中,如下所示: 当我使用$client=2在phpmyadmin中测试查询时我得到以下输出(这是正确的,因为医生的就诊仅适用于客户id 1): 我假设问题在行的某个地方,将adm\u doctor\u visit\

我的代码中出现了一个问题,但是当我在phpmyadmin中测试查询时,我得到了
NULL
(就像它应该的那样)

我想连接两个表以显示有关用户的所有信息。用户表包含有关客户端的基本信息。在我的页面上,我想添加关于用户可能的医生访问、物理治疗师访问和专家治疗的信息。每个连接都存储在不同的表中,如下所示:

当我使用
$client=2在phpmyadmin中测试查询时我得到以下输出(这是正确的,因为医生的就诊仅适用于
客户id 1
):

我假设问题在
行的某个地方,将adm\u doctor\u visit\u记录作为dvr ON dvr.dv\u client\u id=client.c\u id
,因为这是存储医生就诊记录的表。我以为我只是在用户id上加入的,但显然这里出了问题


PS,我刚开始OOP,所以如果我用错误的方式来做,这就是我理解它的方式(尽管开放供建议)

您正在执行一个分组,但您没有提供一个GROUP BY子句。这将导致奇怪/错误的结果。

Aah。。解决了这个问题,不知何故通过
$client
传递了一个错误的参数。奇怪的是怎么会发生这种事。谢谢你的帮助

一般提示:如果您在查询中寻求帮助,则无需显示一英里的php/html。这与让查询正常工作无关。@MarcB:假设OP声明从PHP运行时查询产生的结果与直接在phpMyAdmin中执行时查询产生的结果不同,那么他的PHP代码似乎非常相关。嗯,当我在CONCAT选择的所有行上添加一个GROUP_BY时,我在代码中得到相同的输出,但是当我在phpmyadmin中运行查询时,它显示两行(而不是通常的一行)

+------+-------------+--------------+
| n_id | n_client_id | n_connect_id |
+------+-------------+--------------+
|  1   |     1       |       1      |
+------+-------------+--------------+
|  2   |     1       |       2      |
+------+-------------+--------------+

+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+
| clientId | clientName | clientAddres  | clientZip | clientCity | clientPhone | clientMail   | clientDoctorCompany | clientDoctor | clientPhysioCompany | clientPhysio | clientSpecialist | clientSpecialistsSpecialities | clientDoctorRecords | clientDoctorRecordsDate | clientDoctorRecordsParaph |
+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+
| 1        | Name       | Address 1     | 1234 AB   | City       | 0612345678  | info@url.com | Company 1           | Doctor 1     | Physio Company  1   | Therapist 1  | Specialist 1     | specialty 1, specialty 2      | visit 1             | 2012-11-11              | MK                        |
+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+

+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+
| clientId | clientName | clientAddres  | clientZip | clientCity | clientPhone | clientMail   | clientDoctorCompany | clientDoctor | clientPhysioCompany | clientPhysio | clientSpecialist | clientSpecialistsSpecialities | clientDoctorRecords | clientDoctorRecordsDate | clientDoctorRecordsParaph |
+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+
| 1        | Name       | Address 1     | 1234 AB   | City       | 0612345678  | info@url.com | Company 1           | Doctor 1     | Physio Company  1   | Therapist 1  | Specialist 1     | specialty 1, specialty 2      | NULL                | NULL                    | NULL                      |
+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+

<?php

    class ClientData{
        public $clientId;
        public $clientName;
        public $clientAddress;
        public $clientZip;
        public $clientCity;
        public $clientPhone;
        public $clientMail;
        public $clientDoctor;
        public $clientDoctorCompany;
        public $clientDoctorRecords;
        public $clientDoctorRecordsDate;
        public $clientDoctorRecordsParaph;
        public $clientPhysio;
        public $clientPhysioCompany;
        public $clientSpecialist;
        public $clientSpecialistsSpecialities;
    }

    class clientManagement{

        public $cInfo = Array();
        public $clientInfo = Array();
        public $querystring;

        [..]

        public function getClientDetails($client){

            $dbdata = new mySQLAccessData();
            $db = new PDO($dbdata->hostname,$dbdata->username,$dbdata->password);
            $sql = "
                SELECT 
                    client.c_id AS clientId, client.c_name AS clientName, client.c_address AS clientAddress, client.c_zip AS clientZip, client.c_city AS clientCity, client.c_tel AS clientPhone, client.c_mail AS clientMail, 
                    doctorCompany.d_name AS clientDoctorCompany, 
                    doctor.d_name AS clientDoctor, 
                    physioCompany.p_name AS clientPhysioCompany, 
                    physio.p_name AS clientPhysio, 
                    specialist.s_name AS clientSpecialist, 
                    GROUP_CONCAT(DISTINCT specialities.s_specialty) AS clientSpecialistsSpecialities, 
                    GROUP_CONCAT(DISTINCT dvr.dv_records) AS clientDoctorRecords, 
                    GROUP_CONCAT(DISTINCT dvr.dv_datetime) AS clientDoctorRecordsDate, 
                    GROUP_CONCAT(DISTINCT dvr.dv_paraph) AS clientDoctorRecordsParaph

                FROM adm_clients AS client

                    LEFT JOIN norm_client_doctor AS ncd ON ncd.ncd_client_id = client.c_id
                    LEFT JOIN adm_doctor_company AS doctorCompany ON doctorCompany.d_id = ncd.ncd_doctor_id
                    LEFT JOIN norm_doctor_company AS ndc ON ndc.ndc_company_id = doctorCompany.d_id
                    LEFT JOIN adm_doctor_person AS doctor ON doctor.d_id = ncd.ncd_doctor_id

                        LEFT JOIN adm_doctor_visit_records AS dvr ON dvr.dv_client_id = client.c_id

                    LEFT JOIN norm_client_physio AS ncp ON ncp.ncf_client_id = client.c_id
                    LEFT JOIN adm_physiotherapist_company AS physioCompany ON physioCompany.p_id = ncp.ncf_physio_id
                    LEFT JOIN norm_physio_company AS npc ON npc.nfc_company_id = physioCompany.p_id
                    LEFT JOIN adm_physiotherapist_person AS physio ON physio.p_id = npc.nfc_physio_id

                    LEFT JOIN norm_client_specialist AS ncs ON ncs.ncs_client_id = client.c_id
                    LEFT JOIN adm_specialist_person AS specialist ON specialist.s_id = ncs.ncs_specialist_id
                    LEFT JOIN norm_specialist_specialities AS nss ON nss.nsc_company_id = specialist.s_id
                    LEFT JOIN adm_specialist_specialities AS specialities ON specialities.s_id = nss.nsc_specialist_id

                WHERE client.c_id = '".$client."'
            ";
            $result = $db->query($sql); 
            $obj = $result->setFetchMode(PDO::FETCH_INTO, new ClientData);
            $i = 0;
            foreach($result as $show){
                $i++;
                $this->clientInfo[$i] = new ClientData();
                $this->clientInfo[$i]->clientId = $show->clientId;
                $this->clientInfo[$i]->clientName = $show->clientName;
                $this->clientInfo[$i]->clientAddress = $show->clientAddress;
                $this->clientInfo[$i]->clientZip = $show->clientZip;
                $this->clientInfo[$i]->clientCity = $show->clientCity;
                $this->clientInfo[$i]->clientPhone = $show->clientPhone;
                $this->clientInfo[$i]->clientMail = $show->clientMail;
                $this->clientInfo[$i]->clientDoctor = $show->clientDoctor;
                $this->clientInfo[$i]->clientDoctorCompany = $show->clientDoctorCompany;
                $this->clientInfo[$i]->clientDoctorRecords = $show->clientDoctorRecords;
                $this->clientInfo[$i]->clientDoctorRecordsDate = $show->clientDoctorRecordsDate;
                $this->clientInfo[$i]->clientDoctorRecordsParaph = $show->clientDoctorRecordsParaph;
                $this->clientInfo[$i]->clientPhysioCompany = $show->clientPhysioCompanyclientDoctorRecordsParaph;
                $this->clientInfo[$i]->clientPhysio = $show->clientPhysio;
                $this->clientInfo[$i]->clientSpecialist = $show->clientSpecialist;
                $this->clientInfo[$i]->clientSpecialistsSpecialities = $show->clientSpecialistsSpecialities;
            }
        }

        public function displayClientDetails(){
            $output = '<h3>Klantgegevens</h3>
                <div id="clientInfoContainer">
                <div id="clientStaticInfo">
                    <p><img src="'._BACKEND_URL.'/Inc/Im/icons/user_64.png" class="userImage"></p>
                    <p><small>Klant aangemaakt op 10/12/2012</small></p>
                    <p><small>Laatste wijziging op 10/12/2012</small></p>
                </div>
                <div id="clientDynamicInfo">
                    <table id="clientInfoTable">
                        <colgroup>
                            <col class="tableLabel">
                            <col class="tableValue">
                        </colgroup>
                        <thead>
                            <tr>
                                <th>Label</th>
                                <th>Waarde</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>Naam</td>
                                <td>'.$this->clientInfo[1]->clientName.'</td>
                            </tr>
                            <tr>
                                <td>Adres</td>
                                <td>'.$this->clientInfo[1]->clientAddress.'</td>
                            </tr>
                            <tr>
                                <td>Postcode woonplaats</td>
                                <td>'.$this->clientInfo[1]->clientZip.' '.$this->clientInfo[1]->clientCity.'</td>
                            </tr>
                            <tr>
                                <td>Telefoonnummer</td>
                                <td>'.$this->clientInfo[1]->clientPhone.'</td>
                            </tr>
                            <tr>
                                <td>Email</td>
                                <td>'.$this->clientInfo[1]->clientMail.'</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                </div>
                <div id="physio-visit-list" class="collapseContainer">
                    <h4>Praktijk fysiotherapie: <strong>'.$this->clientInfo[1]->clientPhysioCompany.'</strong>. Behandelend arts: <strong>'.$this->clientInfo[1]->clientPhysio.'</strong></h4>
                    <div class="collapsableContent">
                        <p>'.$this->clientInfo[1]->clientSpecialistsSpecialities.'</p>
                    </div>
                </div>
                <div id="doctor-visit-list" class="collapseContainer">
                    <h4>Dokterspraktijk: <strong>'.$this->clientInfo[1]->clientDoctorCompany.'</strong>. Behandelend arts: <strong>'.$this->clientInfo[1]->clientDoctor.'</strong></h4>
                    <div class="collapsableContent">
                        <p>'.$this->clientInfo[1]->clientDoctorRecords.'</p>
                    </div>
                </div>
            ';
            echo($output);
        }

    }
?>