Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

afzaalmijsons on "fetch data from custom table in wordpress"

$
0
0

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


Viewing all articles
Browse latest Browse all 26892

Trending Articles