How can I take my table I created like this:
global $wpdb; //Get all the wordpress database stuff
$table_prefix = $wpdb->base_prefix; //Get the global prefix for all sites (on a multisite installation)
$table_name = $table_prefix.'wpaa';//Add wpaa behind the prefix
$sql = "CREATE TABLE IF NOT EXISTS `".$table_name."` (....) "; //Create table and its rows. (Rows are ...'d out)
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); //Require something you have to include
dbDelta( $sql ); //Make the actual query
and get all the data out from it in form of an array.
I know how I would do in regular PHP (without wordpress):
$sql = 'SELECT id,foo,bar FROM wp_wpaa';
$result = mysql_query($sql) or die('Error at looking up in database');
$array = mysql_fetch_array($result);
$wpdb->get_results();
has a second parameter for the return format:So this will return an array:
you can take every rows from a table YOUR_TABALE_NAME
"SELECT * FROM {$wpdb->prefix}YOUR_TABALE_NAME"
then with the
get_results()
return it into an array$array
finally you have somthing like this one :