"Armed Forces Americas", 'AE'=>"Armed Forces Europe", 'AL'=>"Alabama", 'AK'=>"Alaska", 'AP'=>"Armed Forces Pacific", 'AS'=>"American Samoa", 'AZ'=>"Arizona", 'AR'=>"Arkansas", 'CA'=>"California", 'CO'=>"Colorado", 'CT'=>"Connecticut", 'DE'=>"Delaware", 'DC'=>"District Of Columbia", 'FL'=>"Florida", 'FM'=>"Micronesia", 'FPO'=>"FPO", 'GA'=>"Georgia", 'GU'=>"Guam", 'HI'=>"Hawaii", 'ID'=>"Idaho", 'IL'=>"Illinois", 'IN'=>"Indiana", 'IA'=>"Iowa", 'KS'=>"Kansas", 'KY'=>"Kentucky", 'LA'=>"Louisiana", 'ME'=>"Maine", 'MD'=>"Maryland", 'MA'=>"Massachusetts", 'MH'=>"Marshall Islands", 'MI'=>"Michigan", 'MN'=>"Minnesota", 'MS'=>"Mississippi", 'MO'=>"Missouri", 'MT'=>"Montana", 'NE'=>"Nebraska", 'NV'=>"Nevada", 'NH'=>"New Hampshire", 'NJ'=>"New Jersey", 'NM'=>"New Mexico", 'NY'=>"New York", 'NC'=>"North Carolina", 'ND'=>"North Dakota", 'OH'=>"Ohio", 'OK'=>"Oklahoma", 'OR'=>"Oregon", 'PA'=>"Pennsylvania", 'PW'=>"Palau", 'RI'=>"Rhode Island", 'SC'=>"South Carolina", 'SD'=>"South Dakota", 'TN'=>"Tennessee", 'TX'=>"Texas", 'UT'=>"Utah", 'VT'=>"Vermont", 'VA'=>"Virginia", 'VI'=>"Virgin Island", 'WA'=>"Washington", 'WV'=>"West Virginia", 'WI'=>"Wisconsin", 'WY'=>"Wyoming", 'PR'=>"Puerto Rico", 'MP'=>"Northern Mariana Islands", ); $case = 1; if(isset($var[2])&&($var[2]!="")) { $state = strtolower($var[2]); $ustate = strtoupper($state); $shortstate = strtoupper($state); $statelink = $classlink.$state."/"; $fullstate = $states[strtoupper($state)]; $case = 2; } if(isset($var[2])&&isset($var[3])&&($var[2]!="")&&($var[3]!="")) { $city1 = strtolower($var[3]); $citylink = $statelink.$city1."/"; $temp = explode("-",$city1); $city = implode(" ",$temp); $fullcity = ucwords($city); $case = 3; if($city1=="all") { include 'allcities-mentalclinics.php'; exit; } } $docsinpage = 20; $count = 0; $link = mysqli_connect("localhost", "root", "pencil123", "medicare"); if (!$link) { echo "Error: Unable to connect to MySQL." . PHP_EOL; echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL; exit; } $definition = ""; if($case==3) { $sql2 = "Select doccount from mentalclinicscount where state='$state' and city='$city'"; } else if($case==2) { $sql2 = "Select sum(doccount) from mentalclinicscount where state='$state' group by state"; } else if($case==1) { $sql2 = "Select sum(doccount) from mentalclinicscount"; } $query2 = MySQLi_query($link,$sql2); $myrow = MySQLi_fetch_array($query2, MYSQLI_BOTH); $nofdocs = $myrow[0]; $npages = ceil($nofdocs/$docsinpage); if($case == 1) { $desc = "Medicare ".$type.". Find Medicare ID, medicare status, NPI number, address and contact details for all medicare enrolled clinics / group practice in USA"; $title = "Medicare ".$type." Address, Contact"; $title1 = "Medicare ".$type." Details"; $header = "Medicare ".$type." in USA"; } else if ( $case == 2) { $desc = "Medicare ".$type." in ".$fullstate.". Find Medicare ID, medicare status, NPI number, address and contact for all medicare enrolled clinics / group practice in ".$fullstate; $title = "Medicare ".$type." in ".$fullstate." - Medicare, NPI Details"; $title1 = "Medicare ".$type." in ".$fullstate." - Medicare Status, Address, Contact"; $header = "Medicare ".$type." in ".$fullstate; } else if ($case == 3) { $desc = "Medicare ".$type." in ".$fullcity.", ".$fullstate.". Find all ".$type." who accept medicare assignments in ".$fullcity.", ".$fullstate; $title1 = $type." in ".$fullcity.", ".$shortstate." Accepting Medicare"; $title = "Medicare ".$type." in ".$fullcity.", ".$shortstate." - Medicare Status, Address, Contact"; $header = "Medicare ".$type." in ".$fullcity.", ".$fullstate; } $advert = ' '; $adlinkresp = ' '; $adlink = ' '; $replace_linkad = ' '; ?> <?php echo $title;?> | MedicareUSA "; } if ($page == 1) { echo ""; } if ($page == 2) { echo ""; } else if($page != 1) { $ppage=$page - 1; $prev=$canonicalurl."?page=".$ppage; echo ""; } if($page!=$npages) { $npage=$page + 1; $next=$canonicalurl."?page=".$npage; echo ""; } ?>

$nofdocs $type found. Showing $showstart - $showend"; if($case!=3) echo ""; /*Select relevant branches*/ $qonpage = 0; if($case==3) { $sql3 = "Select A1,A2,A5,A12,A13,A29,A30,A31,A32,A33,A35,A36,A42,A48,mflag,link from mentalclinics where A32='$state' AND A31='$city' LIMIT $offset, $docsinpage"; } else if($case==2) { $sql3 = "Select A1,A2,A5,A12,A13,A29,A30,A31,A32,A33,A35,A36,A42,A48,mflag,link from mentalclinics where A32='$state' LIMIT $offset, $docsinpage"; } else if($case==1) { $sql3 = "Select A1,A2,A5,A12,A13,A29,A30,A31,A32,A33,A35,A36,A42,A48,mflag,link from mentalclinics LIMIT $offset, $docsinpage"; } $query3 = MySQLi_query($link,$sql3); $doctortax = array( '251S00000X' => "Community/Behavioral Health Agency", '261QM0801X' => "Clinic - Mental Health", '261QM0850X' => "Clinic - Adult Mental Health", '261QM0855X' => "Clinic - Adolescent and Children Mental Health", '273R00000X' => "Hospital Units - Psychiatric Unit", '2084A0401X' => "Psychiatry & Neurology - Addiction Medicine", '2084A2900X' => "Psychiatry & Neurology - Neurocritical Care", '2084B0002X' => "Psychiatry & Neurology - Obesity Medicine", '2084B0040X' => "Psychiatry & Neurology - Behavioral Neurology & Neuropsychiatry", '2084D0003X' => "Psychiatry & Neurology - Diagnostic Neuroimaging", '2084F0202X' => "Psychiatry & Neurology - Forensic Psychiatry", '2084H0002X' => "Psychiatry & Neurology - Hospice and Palliative Medicine", '2084N0008X' => "Psychiatry & Neurology - Neuromuscular Medicine", '2084N0400X' => "Psychiatry & Neurology - Neurology", '2084N0402X' => "Psychiatry & Neurology - Neurology with Special Qualifications in Child Neurology", '2084N0600X' => "Psychiatry & Neurology - Clinical Neurophysiology", '2084P0005X' => "Psychiatry & Neurology - Neurodevelopmental Disabilities", '2084P0015X' => "Psychiatry & Neurology - Psychosomatic Medicine", '2084P0301X' => "Psychiatry & Neurology - Brain Injury Medicine", '2084P0800X' => "Psychiatry & Neurology - Psychiatry", '2084P0802X' => "Psychiatry & Neurology - Addiction Psychiatry", '2084P0804X' => "Psychiatry & Neurology - Child & Adolescent Psychiatry", '2084P0805X' => "Psychiatry & Neurology - Geriatric Psychiatry", '2084P2900X' => "Psychiatry & Neurology - Pain Medicine", '2084S0010X' => "Psychiatry & Neurology - Sports Medicine", '2084S0012X' => "Psychiatry & Neurology - Sleep Medicine", '2084V0102X' => "Psychiatry & Neurology - Vascular Neurology", '101Y00000X' => "Counselor", '101YA0400X' => "Counselor - Addiction (Substance Use Disorder)", '101YM0800X' => "Counselor - Mental Health", '101YP1600X' => "Counselor - Pastoral", '101YP2500X' => "Counselor - Professional", '101YS0200X' => "Counselor - School", '102L00000X' => "Psychoanalyst", '102X00000X' => "Poetry Therapist", '103G00000X' => "Clinical Neuropsychologist", '103GC0700X' => "Clinical Neuropsychologist - Clinical", '103K00000X' => "Behavioral Analyst", '103T00000X' => "Psychologist", '103TA0400X' => "Psychologist - Addiction (Substance Use Disorder)", '103TA0700X' => "Psychologist - Adult Development & Aging", '103TB0200X' => "Psychologist - Cognitive & Behavioral", '103TC0700X' => "Psychologist - Clinical", '103TC1900X' => "Psychologist - Counseling", '103TC2200X' => "Psychologist - Clinical Child & Adolescent", '103TE1000X' => "Psychologist - Educational", '103TE1100X' => "Psychologist - Exercise & Sports", '103TF0000X' => "Psychologist - Family", '103TF0200X' => "Psychologist - Forensic", '103TH0004X' => "Psychologist - Health", '103TH0100X' => "Psychologist - Health Service", '103TM1700X' => "Psychologist - Men & Masculinity", '103TM1800X' => "Psychologist - Mental Retardation & Developmental Disabilities", '103TP0016X' => "Psychologist - Prescribing (Medical)", '103TP0814X' => "Psychologist - Psychoanalysis", '103TP2700X' => "Psychologist - Psychotherapy", '103TP2701X' => "Psychologist - Group Psychotherapy", '103TR0400X' => "Psychologist - Rehabilitation", '103TS0200X' => "Psychologist - School", '103TW0100X' => "Psychologist - Women", '104100000X' => "Social Worker", '1041C0700X' => "Social Worker - Clinical", '1041S0200X' => "Social Worker - School", '106E00000X' => "Assistant Behavior Analyst", '106H00000X' => "Marriage & Family Therapist", '106S00000X' => "Behavior Technician", ); echo ""; while($myrow = MySQLi_fetch_array($query3, MYSQLI_BOTH)) { $npi = $myrow['A1']; $entity = $myrow['A2']; $orgname = $myrow['A5']; $othername = $myrow['A12']; $flag = $myrow['A13']; $cityname = ucwords(strtolower($myrow['A31'])); $statename = $myrow['A32']; $zip = substr($myrow['A33'],0,5); $address1 = ucwords(strtolower($myrow['A29'])); $address2 = ucwords(strtolower($myrow['A30'])); $phone = substr($myrow['A35'],0,3)."-".substr($myrow['A35'],3,3)."-".substr($myrow['A35'],6); if(!empty($myrow['A36'])) $fax = substr($myrow['A36'],0,3)."-".substr($myrow['A36'],3,3)."-".substr($myrow['A36'],6); else $fax =""; //$category = $myrow['category']; $doctortype = $doctortax[$myrow['A48']] ?? "Mental Health Clinic"; //$doctortype = $taxlist2[$category][1]; $doclink = $myrow['link']; if($myrow['mflag']==1) $mflag = "Medicare Enrolled"; else $mflag = "Not Enrolled in Medicare"; if($othername!="" && $flag!=4) { $fullname = $othername; } else { $fullname = $orgname; } $fullname = str_replace(' ',' ',$fullname); $printname = ucwords(strtolower($fullname)); $fulladdress=""; if($address1!="") $fulladdress = $address1.", "; if($address2!="") $fulladdress = $fulladdress.$address2.", "; $fulladdress = $fulladdress.$cityname.", ".$statename." ".$zip; $temp = explode(" ",strtolower($fullname)); $tempname = urlencode(implode("-",$temp)); $temp = explode(" ",strtolower($cityname)); $tempcity = urlencode(implode("-",$temp)); $tempstate = strtolower($statename); $branchlink = $typelink.$doclink."/"; $qonpage++; $medflag = "Yes"; if($qonpage==4) { echo ""; } echo ""; } if($qonpage<4) { echo ""; } echo "
"; echo "$advert"; echo "
"; echo "
\"clinic
"; echo "
$printname
"; echo "$doctortype
Medicare: $mflag
Practice Location: $fulladdress
"; echo "Phone: $phone    "; if(!empty($fax)) echo "Fax: $fax"; echo "
"; echo "
"; echo "$advert"; echo "
"; if($npages>1) { echo "
    "; $diff = max(0, $page+5-$npages); $minpage = max(1, $page-5-$diff); $diff = max(0,1+5-$page); $maxpage = min($npages, $page+5+$diff); $minlink = $urlwithoutparam."?page=".$minpage; $maxlink = $urlwithoutparam."?page=".$maxpage; if($minpage != 1) echo "
  • «
  • "; for ($i=$minpage;$i<=$maxpage;$i++) { $link2 = $urlwithoutparam."?page=".$i; if($i==$page) echo "
  • $i(current)
  • \n"; else echo "
  • $i
  • \n"; } if($maxpage != $npages) echo "
  • »
  • "; echo "
"; } ?>
$adlinkresp"; } else if($case == 2) { $sql4 = "SELECT * from (Select city, doccount from mentalclinicscount where state='$state' AND doccount>2 order by doccount desc limit 30) as t1 order by city"; echo "Top Cities:
"; $query4 = MySQLi_query($link,$sql4); while($myrow = MySQLi_fetch_array($query4, MYSQLI_BOTH)) { $option = ucwords(strtolower($myrow[0])); $countoption = $myrow[1]; $temp = explode(" ",strtolower($option)); $tempcity = urlencode(implode("-",$temp)); $link1 = $statelink.$tempcity."/"; echo "$option ($countoption)
"; } $allcities = $statelink."all/"; echo "
All Cities in $ustate"; } else if($case == 1) { $sql4 = "Select state, sum(doccount) from mentalclinicscount group by state order by state"; echo "Filter By State:
"; $query4 = MySQLi_query($link,$sql4); while($myrow = MySQLi_fetch_array($query4, MYSQLI_BOTH)) { $option = strtolower($myrow[0]); $countoption = $myrow[1]; $state1 = $states[$myrow[0]]; $link1 = $classlink.$option."/"; echo "$state1 ($countoption)
"; } } ?>

$type: Mental health clinics are facilities which provide diagnostic, treatment, and prescriptive services related to mental and behavioral disorders. Mental health services are provided by Psychiatrists, Psychologists, Counselors, and/or other licensed professionals depending on the treatment.

\n"; echo "$advert"; ?>