View Full Version : confusing search

05-18-2008, 01:43 AM
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

05-18-2008, 02:37 AM
// 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.

05-18-2008, 05:13 AM
thank i understand. I was close to this did not quite have it right got it working :)