I’m trying to retrieve a text value for my field from database using this query:
<input type="text" name="last_link" id="last_link" value="<?php global $wpdb; $user_ID = get_current_user_id(); $result= $wpdb->get_results( 'SELECT last_link FROM users WHERE ID = $user_ID'); echo $result; ?>"
I’ve searched a lot but all I could find is Class Reference/wpdb
and I was’t able to find my mistake.
USE
$wpdb->get_var('your query')
instead$wpdb->get_results()
I have found Error in query which is you forget the table prefix that is required to retrieve info from wordpress pre defined tables.
Use
global $table_prefix
along with$wpdb
Like this :
global $wpdb,$table_prefix
Also make sure your column
last_link
is added totableprefix_users
‘s tableFor your requirement use below code to retrieve info.
As stated in Documentation