Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    confusing search

    ok I am just a hobbist programer so bear with me please. I am tring to make a search I use php 4.1 and msqle 3.2 if that matters. here is my problem
    in table 1 I have a text field called area_codes it is listed like this
    931, 723, 716 ect for each entry

    in table 2 I have a table that has area codes and zipcodes I need form that searchs table 2 for a zipcode then determains the area codes that zip is in. then it take that area code and counts the number of times it shows up in table 1..
    Question 1: can it be done?
    question 2: I dont expect anyone to whip up the code for me (would be very nice but let be relistic I am not a paying customer lol) but can some give me a hint or link to such a search. I can not seem to locate one. This is probley due to me not know the proper terms to search for.
    Any clues would be helpful thanks

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    118
    Thanks
    3
    Thanked 9 Times in 9 Posts
    PHP Code:
    // Database connect goes here

    $zipcode //ZIP CODE;

    $query = ("SELECT * FROM /*table 1*/ WHERE /*`column for zip code`*/ = $zipcode");

    $area = (mysql_fetch_array($query));

    $areacode $area['/*column for area code*/'];

    $result = ("SELECT * FROM /*table 2*/ WHERE /*`column for area code`*/ = $areacode");

    $number_of_times_it_appears mysql_num_rows($result);

    // close db connection 
    Of course, you will need to put in your connection strings etc, and tweak the code to your needs. Just don't cut and paste it either, as it may have some small errors that have been looked over.
    Last edited by peteyb383; 05-18-2008 at 01:44 AM. Reason: mistake

  • Users who have thanked peteyb383 for this post:

    webjunkie (05-18-2008)

  • #3
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thank i understand. I was close to this did not quite have it right got it working


  •  

    Posting Permissions

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