Create a table with the following columns:

  • EmailProvider (AUTO INC int primary key)
  • EmailProviderName

//**********************************************
//**********************************************
//********** READ ALL EMAIL PROVIDERS **********
//**********************************************
//**********************************************
/* Example usage
  //Convert EmailProvider ID value to Name
  $Results= db_email_providers_read_all();
  foreach ($Results as $Entry)
  {
    if ($EmailProvider == $Entry['EmailProvider'])
      $EmailProvider = $Entry['EmailProviderName'];
  }
*/
function db_email_providers_read_all ()
{
  global $wpdb;
  
  $sql = "SELECT * FROM {$wpdb->prefix}my_table_name ORDER BY EmailProviderName ASC";
  if (current_user_can('administrator'))
    $wpdb->show_errors();
  $Results = $wpdb->get_results($sql, ARRAY_A);
  if (count($Results) == 0)
    $Results = array();

  //Insert default None entry into the Results array as index 0 (the rest of the array moves down)
  $NoneEntry = array(
    "EmailProvider"=>0,
    "EmailProviderName"=>"Not Selected"
  );
  array_unshift($Results,$NoneEntry);

  
  return($Results);    
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *