If we can forget prior examples: this joins on CountyFIPS to bring up the regions.
What I need is to manually plug into the page various values for Mcateg that are filtered via colname2. There are approximately 25 to 30 diffferent values for this (products or services) that will occur across approxiamately 20-30 CountyFIPS values (regions)
XMem
XmemID – primary // note that all ID’s in these tables are joinable on this.
Mcateg – the “categories”
XMwcat – categores per “subscriber” // composite key table
XMCounty – CountyFIPS per “subscriber” // composite key table and FIPS # is representative of counties
commercial9 - the main lookup table for County/FIPS
$colname_XLA5 = "6037";
if (isset($HTTP_GET_VARS['XLAFIPS'])) {
$colname_XLA5 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['XLAFIPS'] : addslashes($HTTP_GET_VARS['XLAFIPS']);
}
$colname2_XLA5 = "0";
if (isset( $HTTP_POST_VARS['MCatID'])) {
$colname2_XLA5 = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['MCatID'] : addslashes( $HTTP_POST_VARS['MCatID']);
}
mysql_select_db($database_removed, $removed);
$query_XLA5 = sprintf("SELECT COUNT(*) as theCount FROM XMem, Mcateg INNER JOIN XMcounty ON XMem.XMemID = XMcounty.XMcXMemID INNER JOIN commercial9 ON commercial9.CountyFIPS =XMcounty.XMcountyFIPS AND commercial9.CommID = (SELECT max( commercial9.CommID ) FROM commercial9 WHERE CountyFIPS = '%s' ) INNER JOIN XMwcat ON XMem.XMemID = XMwcat.XMwXMemID WHERE XMwcat.XMwCatID = Mcateg.MCatID AND Mcateg.MCatID = '%s' GROUP BY NULL ", $colname_XLA5,$colname2_XLA5);
$XLA5 = mysql_query($query_XLA5, $removed) or die(mysql_error());
$row_XLA5 = mysql_fetch_assoc($XLA5);
$totalRows_XLA5 = mysql_num_rows($XLA5);