Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:36:19+00:00 2026-06-14T05:36:19+00:00

I have a problem that occurs in my code, but when i test the

  • 0

I have a problem that occurs in my code, but when i test the query in phpmyadmin i get NULL (like it’s supposed to be)

I want to join a couple of tables to display all information about a user. The user table contains the basic information about a client. On my page i want to add information about a users possible doctor visits, physiotherapist visits and treatments by specialist. Every connection is stored in a different table, like so:


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

n_connect_id can either be the id of the doctor's- physiotherpist's and/or specialist's record that is stored in the matching tables.

Because not all users will have records in all three (doctors, physiotherapists and specialist) tables, so in some cases NULL will be the output.

When i test my query in phpmyadmin with $client = 1; i get the following output (which is correct since the doctor's visits only apply to client_id 1):


+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+
| 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                        |
+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+

When i test my query in phpmyadmin with $client = 2; i get the following output (which is correct since the doctor's visits only apply to client_id 1):


+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+
| 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                      |
+----------+------------+---------------+-----------+------------+-------------+--------------+---------------------+--------------+---------------------+--------------+------------------+-------------------------------+---------------------+-------------------------+---------------------------+

When i run the code on my website it constantly outputs all the records, no mather if i change the $client

This is the code i use


<?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);
        }

    }
?>

I assume the problem is somewhere iin the line LEFT JOIN adm_doctor_visit_records AS dvr ON dvr.dv_client_id = client.c_id, since that's the table that stores the doctor visit records. I thought i joined it only on the user_id but apparently something's going wrong here.

PS, i just started OOP so if i'm doing it the wrong way, this is the way i understand it (open for suggestions though)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:36:20+00:00Added an answer on June 14, 2026 at 5:36 am

    Aah.. solved it, was somehow passing a wrong parameter via $client. Weird how it could happen though. Thanks for the help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that occurs only in a production environment, deployed at heroku.
I have encountered a most annoying problem that occurs on the PWD variable when
I have a problem that has been driving me batty. I have code that
(I have a problem that I illustrated in this question but had no correct
I have a piece of templated code that is never run, but is compiled.
I have a strange problem. My compilerwarnings look like code\/log_event.h:59:16: warning: 'xxxxxx' code\/log_event.h:58:18: warning:
I test the code in IE7, FF, Chrome, Safari and this problem occurs in
I have some relatively simple code I have made that is supposed to retrieve
I have a webpage that plays a 'chime' sound when certain events occur. Problem
In a couple of scripts that I use I have problem that is intermittent.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.