I have SQL file with US zip codes (over 41000 lines of code). I want make a plugin that inserts this SQL file into WP database so user can do a search by zip codes. I want to insert SQL with PHP rather than PhpMyAdmin
Leave a Reply
You must be logged in to post a comment.
See the WordPress Codex on Creating Tables with Plugins.
I have not created a plugin that does what you want, but I have been playing with a plugin that creates its own tables.
The plugin in comes with an SQL.txt file in case your WordPress install does not have permissions to create tables (in which case you would have to manually run the SQL file)
So it seems that a plugin that creates tables could potentially be problematical during install.
Another thing that this same plugin does is use an array from another file to display things. This seems like it would be a better approach because you would not have to mess with people’s DB, and you could easily update the file that holds your array of zip codes.
Here is some of the code it uses for doing that: