How to automatically alert your users about events happening in their area

This can be easily done if you are already geocoding users addresses (i.e. getting their latitude and longitude) while they register on your website.

If you are not doing so then you can go back and geocode all the previous addresses.

Now lets assume you have geocoded all the addresses and are storing them in a separate table as shown below

Table: user_lat_long

Now create a function to get users from the above table near a certain address (where the event is to be held).

Now just call the above function with 3 parameters as input

  1. Radius => Defines the area you want to set to alert your users e.g. 100 KM
  2. Latitude => Latitude of the place where the event is to be held
  3. Longitude => Longitude of the place where the event is to be held