I have table called wp_email_subscription and inside table I have rows of emails from subscribed users. Each row contains id, email, and name column.
I have also created admin page for plugin where I would like to list all emails from subscribed table.
Basically I don't know how to use wpdb functions, I have read wpdb instructions from wp website but I don't understand.
what I need is to select all from wp_email_subscription and foreach row to display email and name column in list.
Creating Tables in the WordPress Block Editor Simply create a new post or page, or edit an existing one. Once inside the content editor, click on the (+) symbol to add a new block, then select 'Table'. You can find it under the 'Formatting' section ,or you can type 'Table' into the 'Search for a block' bar.
The first command you will need to use is the SELECT FROM MySQL statement that has the following syntax: SELECT * FROM table_name; This is a basic MySQL query which will tell the script to select all the records from the table_name table.
you have to use global wpdp
variable and get_result
function in your code page like this...
global $wpdb;
$row = $wpdb->get_results( "SELECT * FROM wp_email_subscription");
foreach ( $row as $row )
{ echo "email:".$row->email.";} //$row->your_column_name in table
like this, you can access all columns by $variable->col_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With