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);    
}
UK Electronic Designer
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published.