Learn how to import regions/locations to DJ-Classifieds
When you need to have many locations/regions in your classifieds website it can be hard to add them one by one. This is why we created this tutorial on how to import all the locations at once directly to your database.
You’ll need to be able to access your database via phpMyAdmin.
First, you need to prepare the .csv file with all the regions you want to add (You’ll find the exemplary .csv file at the end of the article).
Please note that the locations should be imported into an empty table of DJ-Classifieds regions.
The structure of the .csv file you'll need is quite straight forward:
in Microsoft Excel it will look like this:
The first row has this columns:
- id - ID of the region
- name - name of the region
- parent_id - if the region is child item of other region you put the parent region ID there
- country - if the region is a country you need to use 1, otherwise use 0
- city - if the region is a city you need to use 1, otherwise use 0
- published - use 0 or 1 to determine if the region will be published after import
- latitude - latitude coordinates (you don’t need to use them but it’s needed to have that column in .csv)
- longitude - longitude coordinates (you don’t need to use them but it’s needed to have that column in .csv)
In following rows, you insert the values basing on the scheme.
Once you’re ready with your .csv file you can move to import it to the database.
First open your Cpanel account, open phpMyAdmin
When in phpMyAdmin open your database and find regions table and open it (the name of the table will be [yourdbprefix]_djcf_regions )
Next ( when in regions table ) click „Import” in the top bar
Now you’re ready to import the .csv file
- browse for the .csv file
- make sure to skip the first row (insert „1”)
- insert „;” (semicolon) in Columns separated with:
- Enter Column names: id,name,parent_id,country,city,published,latitude,longitude,country_iso
- click „Go”
Imported regions/locations are now visible in your DJ-Classifieds
You can download exemplary .csv file with regions here: DJ-Classifieds regions / locations exemplary .csv ( 9.34 kB )
Download pre-made databases:
If you're seeing "Invalid column count" error when importing the .csv file via phpMyAdmin, add the following text in the "Column names:" in case the Regions table have more columns than the imported .csv file (this can happen when we update DJ-Classifieds):