Insert list of US states into a taxonomy

This SQL will add a list of US states to a particular taxonomy. You will need to search for the string %vid and replace with the actual numeric vid of your vocabulary (which you can get from the URL on /admin/taxonomy. You may wish to delete the initial 'National' entry.

You will also need to update the term_data_tid value in the sequences table, and add initial values to the term_hierarchy table (INSERT INTO term_hierarchy VALUES (%tid, 0) for each new tid. Whew. Anyone want to make a php snippet to do all this? ;-)

INSERT INTO term_data VALUES
('', %vid, 'National', '', 0),
('', %vid, 'Alabama', '', 0),
('', %vid, 'Alaska', '', 0),
('', %vid, 'Arizona', '', 0),
('', %vid, 'Arkansas', '', 0),
('', %vid, 'California', '', 0),
('', %vid, 'Colorado', '', 0),
('', %vid, 'Connecticut', '', 0),
('', %vid, 'Delaware', '', 0),
('', %vid, 'Florida', '', 0),
('', %vid, 'Georgia', '', 0),
('', %vid, 'Hawaii', '', 0),
('', %vid, 'Idaho', '', 0),
('', %vid, 'Illinois', '', 0),
('', %vid, 'Indiana', '', 0),
('', %vid, 'Iowa', '', 0),
('', %vid, 'Kansas', '', 0),
('', %vid, 'Kentucky', '', 0),
('', %vid, 'Louisiana', '', 0),
('', %vid, 'Maine', '', 0),
('', %vid, 'Maryland', '', 0),
('', %vid, 'Massachusetts', '', 0),
('', %vid, 'Michigan', '', 0),
('', %vid, 'Minnesota', '', 0),
('', %vid, 'Mississippi', '', 0),
('', %vid, 'Missouri', '', 0),
('', %vid, 'Montana', '', 0),
('', %vid, 'Nebraska', '', 0),
('', %vid, 'Nevada', '', 0),
('', %vid, 'New Hampshire', '', 0),
('', %vid, 'New Jersey', '', 0),
('', %vid, 'New Mexico', '', 0),
('', %vid, 'New York', '', 0),
('', %vid, 'North Carolina', '', 0),
('', %vid, 'North Dakota', '', 0),
('', %vid, 'Ohio', '', 0),
('', %vid, 'Oklahoma', '', 0),
('', %vid, 'Oregon', '', 0),
('', %vid, 'Pennsylvania', '', 0),
('', %vid, 'Rhode Island', '', 0),
('', %vid, 'South Carolina', '', 0),
('', %vid, 'South Dakota', '', 0),
('', %vid, 'Tennessee', '', 0),
('', %vid, 'Texas', '', 0),
('', %vid, 'Utah', '', 0),
('', %vid, 'Vermont', '', 0),
('', %vid, 'Virginia', '', 0),
('', %vid, 'Washington', '', 0),
('', %vid, 'West Virginia', '', 0),
('', %vid, 'Wisconsin', '', 0),
('', %vid, 'Wyoming', '', 0);

optionally use helpers module.

Bèr Kessels - May 30, 2006 - 08:46

helpers module has a function that makes a list of states, in addition it has helper functions to use these lists in forms.

---
Professional | Personal
| Sympal: Development and Hosting

 
 

Drupal is a registered trademark of Dries Buytaert.