Login   Register  
PHP Classes
elePHPant
Icontem

File: class.states.inc.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kevin Hagel  >  states  >  class.states.inc.php  >  Download  
File: class.states.inc.php
Role: ???
Content type: text/plain
Description: US States select-option
Class: states
Author: By
Last change:
Date: 2002-01-08 15:18
Size: 3,119 bytes
 

Contents

Class file image Download
<?php
/*****************************************************\
*
* Author:  Kevin Hagel
* Date:    1/8/2002
* statecodes.inc.php - another kludgo to create a bunch of
*  <OPTION VALUE="sc">state</OPTION> kinds of things.
*
\*****************************************************/
class states
{
  var $classname = "state";
  var $state_hash = array(
      "select" => "Select State",
      "al"  => "Alabama",
      "ak"  => "Alaska",
      "as"  => "American Samoa",
      "az"  => "Arizona",
      "ar"  => "Arkansas",
      "ca"  => "California",
      "co"  => "Colorado",
      "ct"  => "Connecticut",
      "de"  => "Delaware",
      "dc"  => "District Of Columbia",
      "fm"  => "Federated States Of Micronesia",
      "fl"  => "Florida",
      "ga"  => "Georgia",
      "gu"  => "Guam",
      "hi"  => "Hawaii",
      "id"  => "Idaho",
      "il"  => "Illinois",
      "in"  => "Indiana",
      "ia"  => "Iowa",
      "ks"  => "Kansas",
      "ky"  => "Kentucky",
      "la"  => "Louisiana",
      "me"  => "Maine",
      "mh"  => "Marshall Islands",
      "md"  => "Maryland",
      "ma"  => "Massachusetts",
      "mi"  => "Michigan",
      "mn"  => "Minnesota",
      "ms"  => "Mississippi",
      "mo"  => "Missouri",
      "mt"  => "Montana",
      "ne"  => "Nebraska",
      "nv"  => "Nevada",
      "nh"  => "New Hampshire",
      "nj"  => "New Jersey",
      "nm"  => "New Mexico",
      "ny"  => "New York",
      "nc"  => "North Carolina",
      "nd"  => "North Dakota",
      "mp"  => "Northern Mariana Islands",
      "oh"  => "Ohio",
      "ok"  => "Oklahoma",
      "or"  => "Oregon",
      "pw"  => "Palau",
      "pa"  => "Pennsylvania",
      "pr"  => "Puerto Rico",
      "ri"  => "Rhode Island",
      "sc"  => "South Carolina",
      "sd"  => "South Dakota",
      "tn"  => "Tennessee",
      "tx"  => "Texas",
      "ut"  => "Utah",
      "vt"  => "Vermont",
      "vi"  => "Virgin Islands",
      "va"  => "Virginia",
      "wa"  => "Washington",
      "wv"  => "West Virginia",
      "wi"  => "Wisconsin",
      "wy"  => "Wyoming"
  );

  /*********** FUNCTIONS ***********/

  function stateHash()
  {
    return $this->state_hash;
  }


  function stateOptions($select="")
  {
    strtolower($select);
    if(!$select) {
      $str = "<OPTION VALUE=\"select\">Select State</OPTION\n";
    }
    while(list($sc,$sv)=each($this->state_hash)) {
      $selected = strcmp($sc,$select)==0?'SELECTED':"";
      $str .= "<OPTION VALUE=\"$sc\" $selected>$sv</OPTION>\n";
    }
    reset($this->state_hash);
    return $str;
  }


  /*********************************************\
  *
  * stateSelect - builds the whole selection for you
  *  with paramters.
  *
  \*********************************************/
  function stateSelect($parms="",$selected="")
  {
    $str = "<SELECT ";
    while(list($a,$v)=each($parms))
      $str.="$a=\"$v\" ";
    $str.=">\n";
    $str .= $this->stateOptions($selected)
         .  "</SELECT>\n";
    return $str;
  }


} // class states
?>