Title: fetch data from custom table in wordpress
Last modified: August 22, 2016

---

# fetch data from custom table in wordpress

 *  [afzaalmijsons](https://wordpress.org/support/users/afzaalmijsons/)
 * (@afzaalmijsons)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/fetch-data-from-custom-table-in-wordpress/)
 * hello every one i am new in wordpress developer . i am developing a plugin that
   is getting id from user and save it in to my custom table i am trying to fetch
   data from my table but failed please help me out it Thanks in advance
    ** how
   i fetch this data? ** here is my code
 * global $jal_db_version;
    $jal_db_version = ‘1.0’; function jal_install() { global
   $wpdb; global $jal_db_version;
 *  $table_name = $wpdb->prefix . ‘coachid’;
 *  /*
    * We’ll set the default character set and collation for this table. * If
   we don’t do this, some characters could end up being converted * to just ?’s 
   when saved in our table. */ $charset_collate = ”;
 *  if ( ! empty( $wpdb->charset ) ) {
    $charset_collate = “DEFAULT CHARACTER SET{
   $wpdb->charset}”; }
 *  if ( ! empty( $wpdb->collate ) ) {
    $charset_collate .= ” COLLATE {$wpdb->collate}”;}
 *  $sql = “CREATE TABLE $table_name (
    id mediumint(9) NOT NULL AUTO_INCREMENT,
   time datetime DEFAULT ‘0000-00-00 00:00:00’ NOT NULL, name tinytext NOT NULL,
   text text NOT NULL, url varchar(55) DEFAULT ” NOT NULL, UNIQUE KEY id (id) ) 
   $charset_collate;”;
 *  require_once( ABSPATH . ‘wp-admin/includes/upgrade.php’ );
    dbDelta( $sql );
 *  add_option( ‘jal_db_version’, $jal_db_version );
    }
 * function jal_install_data() {
    global $wpdb;
 *  $id =’xxxxxxx’;
    //$welcome_text = ‘Congratulations, you just completed the 
   installation!’;
 *  $table_name = $wpdb->prefix . ‘cachid’;
 *  $wpdb->insert(
    $table_name, array( ‘time’ => current_time( ‘mysql’ ), ‘name’
   => $id, ) ); }

The topic ‘fetch data from custom table in wordpress’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [afzaalmijsons](https://wordpress.org/support/users/afzaalmijsons/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/fetch-data-from-custom-table-in-wordpress/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
