How to list all rows from table and display specific column data from wordpress database

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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