A
Anonymous
Guest
I have two tables, contacts & zips
In the contacts table I have a field for custProduct, custState and in the zips table I have a field for zState
This is a two character field (ie. SC or TC or MI, etc....) I use the zips table as the reference table.
Basically I want to run a query that checks to see which states do not have a contact currently. I will be adjusting the query to also look for specific products NOT carried in what states. I have included what I have for a query currently ... This is probably archaic and not correct in the manner in which I have written it, because it is not returning the data right. And I am new at this ... so forgive me ... I think I need to do a join somehow but am a little confused. Thanks in advance for any help you can give.
In the contacts table I have a field for custProduct, custState and in the zips table I have a field for zState
This is a two character field (ie. SC or TC or MI, etc....) I use the zips table as the reference table.
Basically I want to run a query that checks to see which states do not have a contact currently. I will be adjusting the query to also look for specific products NOT carried in what states. I have included what I have for a query currently ... This is probably archaic and not correct in the manner in which I have written it, because it is not returning the data right. And I am new at this ... so forgive me ... I think I need to do a join somehow but am a little confused. Thanks in advance for any help you can give.
Code:
<?php
$query = "SELECT * from zips,contacts where zState != custState ORDER BY zState ASC";
$result = mysql_query($query);
while ($rows = mysql_fetch_object($result))
{
$query2="Select * FROM contacts";
$result2= mysql_query($query2);
while ($rows2 = mysql_fetch_object($result2))
{
$custState = $rows2->custState;
}
if (($custState) != ($rows->zState))
{
echo '<font size=2><br><b>State:</b> ' . $rows->zState . ' <b>Zip Range:</b> ' . $rows->zRange . '</font><br>';
}
}
echo "<br><br>There is no coverage in the following areas listed above.";