Title: Trouble loading database data
Last modified: August 21, 2016

---

# Trouble loading database data

 *  [Archie Makuwa](https://wordpress.org/support/users/archie22is/)
 * (@archie22is)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/trouble-loading-database-data/)
 * Hey guys,
 * I have the following table: ‘wp_customercounts’ with the following fields: ‘customercountid(
   unique and auto generated)’, customerid (post_id)’ and ‘logged_date’.
 * I want to return the number of counts / clicks that are being stored in the database
   table. At the moment I have the following script. It should load everything when
   no customer is selected and only load only the details of a selected customer
   when selected. Here is the code:
 *     ```
       /**
        * Load Admin Report
        */
   
       function loadCustomerReport() {
   
       	global $wpdb;
   
       	$customer_id = $_POST['id']; // customer id
       	$from_date = $_POST['from']; // from date
       	$to_date = $_POST['to']; // to date
   
       	if ($customer_id == 0){
       		$sql=" CALL GetCustomerClicks(NULL,'". $from_date ."', '".$to_date."')";
       	}else{
       		$sql=" CALL GetCustomerClicks('". $customer_id ."','". $from_date ."', '".$to_date."')";
       	}
   
       		$posts = $wpdb->get_results($sql);
   
       		echo("<table class='report'>");
       		echo("<tr><th>Company</th>");
       		echo("<th>Hits</th></tr>");
   
       		foreach ($posts as $post)
       		{
       			echo("<tr>");
       			echo('<td>'.$post->Company.'</td>');
       			echo('<td>'.$post->Hits.'</td>');
       			echo("</tr>");
       		}
   
       		echo("</table>");
   
       		die;
   
       }
       ```
   
 * The weird part is the code works on my localhost – but fails to load on the live
   server – any ideas?

The topic ‘Trouble loading database data’ is closed to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [retrieve data](https://wordpress.org/support/topic-tag/retrieve-data/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Archie Makuwa](https://wordpress.org/support/users/archie22is/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/trouble-loading-database-data/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
