阅读wpdb
文档,别忘了protect your query:
global $wpdb;
$table_name = $wpdb->prefix . "item";
$login_name = sanitize_user( $_POST[\'login_name\'] ); //assuming you\'re dealing with username
$prepare = $wpdb->prepare( "SELECT * FROM $table_name WHERE uname = %s", $login_name );
$myrows = $wpdb->get_results( $prepare );
//output results
echo \'<pre>\' . print_r( $myrows, true ) . \'</pre>\';