title: How to retrieve data from database and display it in table
body: <p>I am using WordPress and the global class <strong>$wpdb</strong> in order to retrieve data from MySQL database and display the results in a table.</p>
  
  <p>I have 4 dropdown list that allow the user to select the required inputs then based on the selected inputs the system display all the related data for the user selection.</p>
  
  <p>When I try to run the code it display error:</p>
  
  <p><strong>Notice: Array to string conversion</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/iHOTm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iHOTm.png" alt="web page display the error"></a></p>
  
  <h1>first part  of code :</h1>
  
  <pre><code>&lt;?php
      /*
      Template Name: search info
      */
  
      get_header();
      ?&gt;
  
      &lt;?php
      // code for submit button ation
      global $wpdb,$_POST;
  //variables that handle the retrieved data from mysql database
  if(isset($_POST['site_name'])) 
        { 
         $site_name=$_POST['site_name'];
        }
        else { $site_name=""; }
  
  if(isset($_POST['owner_name'])) 
       {
        $owner_name=$_POST['owner_name']; 
       } 
       else { $owner_name=""; }
  
  if(isset($_POST['Company_name'])) 
       {
        $company_name=$_POST['Company_name'];
       } 
       else { $company_name=""; }
  
  if(isset($_POST['Subcontractor_name'])) 
      { 
       $Subcontractor_name=$_POST['Subcontractor_name']; 
      }
      else { $Subcontractor_name="";}
  
  
  $site_id = ['siteID'];
  $equipment_type = ['equipmentTYPE'];
  $lat=['latitude'];
  $long=['longitude'];
  $height = ['height'];
  $owner_contact = ['ownerCONTACT'];
  $sub_contact = ['subcontractorCONTACT'];
  $sub_company = ['subcontractorCOMPANY'];
  
  
     if(isset($_POST['query_submit']))
     {
  //query to retrieve all  related info of the selected data from the dropdown list  
  $query_submit =$wpdb-&gt;get_results ("select 
  
  site_info.siteID,site_info.siteNAME ,site_info.equipmentTYPE,site_coordinates.latitude,site_coordinates.longitude,site_coordinates.height ,owner_info.ownerNAME,owner_info.ownerCONTACT,company_info.companyNAME,subcontractor_info.subcontractorCOMPANY,subcontractor_info.subcontractorNAME,subcontractor_info.subcontractorCONTACT from `site_info`
  LEFT JOIN `owner_info`
  on site_info.ownerID = owner_info.ownerID
  LEFT JOIN `company_info` 
  on site_info.companyID = company_info.companyID
  LEFT JOIN `subcontractor_info` 
  on site_info.subcontractorID = subcontractor_info.subcontractorID
  LEFT JOIN `site_coordinates` 
  on site_info.siteID=site_coordinates.siteID 
  
  where 
  site_info.siteNAME = `$site_name` 
  AND
  owner_info.ownerNAME = `$owner_name`
  AND
  company_info.companyNAME = `$company_name`
  AND
  subcontractor_info.subcontractorNAME = `$Subcontractor_name`
   ");
   ?&gt;
      &lt;table width="30%" &gt;
          &lt;tr&gt;
             &lt;td&gt;Site Name&lt;/td&gt;
             &lt;td&gt;Owner Name&lt;/td&gt;
             &lt;td&gt;Company Name&lt;/td&gt;
             &lt;td&gt;Subcontractor Name&lt;/td&gt;
           &lt;/tr&gt;
           &lt;tr&gt;
              &lt;td&gt;&lt;?php echo $site_name ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $owner_name ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $company_name ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $Subcontractor_name ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $site_id ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $equipment_type ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $lat ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $long ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $height ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $owner_contact ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $sub_contact ; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $sub_company ; ?&gt;&lt;/td&gt;
  
  
           &lt;/tr&gt;
      &lt;/table&gt;
      &lt;?php }  ?&gt;
  </code></pre>
  
  <p>The second part of code is for retrieve data from database and includes it in the dropdown list.</p>
  
  <p>I will appreciate any help.</p>