View Issue Details

IDProjectCategoryView StatusLast Update
0008242phpList 3 applicationGeneralpublic20-04-10 04:08
Reporterkyleknapp Assigned To 
Status newResolutionopen 
Product Version2.10.2 
Target VersionFuture developments 
Summary0008242: Method for Selecting Recipients by Zip Code
DescriptionIt is EXTREMELY important to me to be able to target mail recipients by zip code, and phplist just doesn't have any workable way to do this. So here is a solution. It's not elegant (maybe someone could improve on it?), but it does work.

It requires that you have attributes in your database as:

      'Zip Code' (type: textline)
      'Targeted' (type: checkbox)
      (these can be named anything)

Files attached are:

      targetzip.php (the script that does the job) (sample list of zip codes to be targeted)
      listattr.php (displays your attributeIDs)

In the attached targetzip.php script, you'll need to change your database login parameters, as well as the following 2 variables:

      $zipcodeattr = "7"; //attributeid for zipcode field
      $targetdattr = "16"; //attributeid for 'targeted' field

These must be replaced with the appropriate attributeid's from your database (CAUTION: if you get these wrong you could erase valuable data. Your attribute definitions are stored in table 'phplist_user_attribute'. You can view it using something like phpMyAdmin, or use the attached quick & dirty script 'listattr.php' to list your user-defined attributes)

Okay, here's how it works: the script 'targetzip.php'

      -first clears all 'targeted' flags from any previous selection, then

      -reads zipcodes from'' (the attached sample is a list of all zip codes within 100 miles of Wheaton IL)

      -generates a list of userids matching each zipcode in the list, and

      -sets the 'targeted' flag to 'on' for each user that matches

You can then use your 'targeted' attribute as a mailing criterion.

To determine what zip codes are selected, simply edit '' using Excel or a text editor and re-upload. I use a program called 'Zip Code Distance Wizard' to find zipcodes within a specified radius of my target location.

Hope this helps someone. I'm a total newbie at PHP and mySQL, but I sure learned a lot doing this.
TagsNo tags attached.


child of 0003292 new plugin API functionality 


13-10-06 22:44 (3,784 bytes)


14-10-06 02:07

administrator   ~0019932

That's very interesting for sure, and I can imagine it will be useful for other people. Have you posted it in the "mods" forum? If so, can you post the thread here, so it can be monitored?

I think people are more likely to search the forums for contributions like this.


14-10-06 03:09

reporter   ~0019937

well, actually I posted it first in the "Answers,Howtos" forum at (but for some reason I was not able to upload the attachment there). Hernol suggested I post it here.

Should I post it in the "Mods" forum as well?


14-10-06 03:40

administrator   ~0019938

no, that's fine thanks. Just one links into the forums will be sufficient


23-04-08 21:03


It is posted on the forum by kyleknapp in the following adress: