SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help: User inputs a post or zip code and gets data from nearby zips codes

    Hi there,
    i've been trying to solve this and am going mad. Please help. I'm working with a community group and i'm a real novice at this :'(

    We have an asp page called input.asp where a user puts in their postcode(zip) code which is 4 numbers e.g. 2050. The idea is that the page input.asp searches a table called Events in an Access database to find out "what's on" in and around their postcode and the results of the search are reported on a page called resultsevents.asp. We want it to report events for a range of postcodes nearby e.g. if the user types in 2050 they should get information for what's on at 2040, 2041, 2042 etc up to 2060 and everything in between.

    I've been sitting here for six hours trying to get the syntax right! I've tried BETWEEN I've TRIED < and > and I've tried everything I know till I'm about to burst into tears.

    Right now the 250th try the section of code in resultsevents.asp looks like :

    SQL_SearchWhere = "(Postcode BETWEEN ('Postcode%-10 AND Postcode+10" & SearchFor & "%'))"

    I can't get it turn return any results except for those that exactly match the postcode input by the user on input.asp

    Please , if you can help I would be very grateful.

    thank you!

    K

  2. #2
    SitePoint Enthusiast hombre_de_las_ca's Avatar
    Join Date
    Apr 2005
    Location
    Bangalore, India
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this:

    var1 = 2050 ' initialize it which ever way you want!
    var2 = var1 + 10
    if var1 > 10 then
    var3 = var1 - 10 'in case u have a code 0010!!!
    else
    var3 = 0001
    end if
    next, use data shaping for the same and print.


    Again i would say use Visual studio (if u have a copy of it) and generate the sql statement (you can get tips on doing that by searching on google or which ever is yur fav search engine).
    If u dont have Visual Studio then try the hard way to create one...check the resources on th net or some book to learn data shaping ..
    U can try the following link if u like:www.asp101.com/articles/chris/datashaping/default.asp

    Again, there coud be other ways of doing the same but since no one replied i thought this might help

    hombre_de_las_cavernas
    Don't ask what your Country can do for you,
    Ask what you can do for your Country.

  3. #3
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you keeping the Postcode as String or Integer? You can use Integer and when you display you can add "0" in front of it.
    And according to that, what about this code:

    Code:
    SQL = SQL & " Where Postcode > " & Inputted_Post_Code - 10 & " and Postcode < " & Inputted_Post_Code + 10
    Also if the number entered is less then 10 it does not give any error, I think, and will work properly.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •