Я использую массив PHP и foreach l oop, чтобы создать раскрывающийся список из 50 штатов США со ссылками на каждую из их страниц ответов COVID-19.
Когда "Go "нажата кнопка, она приведет вас к ссылке выбранного состояния.
Я запускаю тесты, но кнопка" Go "не работает ни для одного из вариантов.
Вот код PHP:
<html>
<body>
<?php
$states = array(
"Alabama" => "governor.alabama.gov/newsroom/covid-19",
"Alaska" => "dhss.alaska.gov/dph/Epi/id/Pages/COVID-19/default.aspx",
"Arizona" => "www.azdhs.gov/index.php",
"Arkansas" => "www.healthy.arkansas.gov/programs-services/topics/novel-coronavirus",
"California" => "www.cdcr.ca.gov/covid19/",
"Colorado" => "covid19.colorado.gov/",
"Connecticut" => "portal.ct.gov/Coronavirus",
"Delaware" => "coronavirus.delaware.gov/",
"District of Columbia" => "https://coronavirus.dc.gov/",
"Florida" => "www.floridadisaster.org/covid19/",
"Georgia" => "georgia.gov/covid-19-state-services-georgia",
"Hawaii" => "health.hawaii.gov/coronavirusdisease2019/",
"Idaho" => "coronavirus.idaho.gov/",
"Illinois" => "coronavirus.illinois.gov/s/",
"Indiana" => "coronavirus.in.gov/",
"Iowa" => "coronavirus.iowa.gov/",
"Kansas" => "govstatus.egov.com/coronavirus",
"Kentucky" => "governor.ky.gov/covid19",
"Louisiana" => "ldh.la.gov/coronavirus/",
"Maine" => "www.maine.gov/covid19/",
"Maryland" => "coronavirus.maryland.gov/",
"Massachusetts" => "www.mass.gov/resource/information-on-the-outbreak-of-coronavirus-disease-2019-covid-19",
"Michigan" => "www.michigan.gov/coronavirus",
"Minnesota" => "mn.gov/covid19/",
"Mississippi" => "msdh.ms.gov/msdhsite/_static/14,0,420.html#Mississippi",
"Missouri" => "dss.mo.gov/covid-19/",
"Montana" => "covid19.mt.gov/",
"Nebraska" => "dhhs.ne.gov/pages/Coronavirus.aspx",
"Nevada" => "nvhealthresponse.nv.gov/",
"New Hampshire" => "www.nh.gov/covid19/",
"New Jersey" => "www.nj.gov/health/cd/topics/covid2019_community.shtml",
"New Mexico" => "www.dws.state.nm.us/COVID-19-Info",
"New York" => "coronavirus.health.ny.gov/home",
"New York City" => "www1.nyc.gov/site/coronavirus/index.page",
"North Carolina" => "www.ncdhhs.gov/divisions/public-health/covid19",
"North Dakota" => "www.ndresponse.gov/covid-19-resources",
"Ohio" => "coronavirus.ohio.gov/wps/portal/gov/covid-19/home",
"Oaklahoma" => "coronavirus.health.ok.gov/",
"Oregon" => "coronavirus.oregon.gov/",
"Pennsylvania" => "www.health.pa.gov/topics/disease/coronavirus/Pages/Coronavirus.aspx",
"Rhode Island" => "www.ride.ri.gov/InsideRIDE/AdditionalInformation/Covid19.aspx",
"South Carolina" => "www.scdhec.gov/infectious-diseases/viruses/coronavirus-disease-2019-covid-19",
"South Dakota" => "covid.sd.gov/",
"Tennessee" => "www.tn.gov/governor/covid-19.html",
"Texas" => "dshs.texas.gov/coronavirus/",
"Utah" => "coronavirus.utah.gov/",
"Vermont" => "www.healthvermont.gov/response/coronavirus-covid-19",
"Virgina" => "www.vdh.virginia.gov/coronavirus/",
"Washington" => "coronavirus.wa.gov/",
"West Virginia" => "dhhr.wv.gov/COVID-19/Pages/default.aspx",
"Wisconsin" => "www.dhs.wisconsin.gov/covid-19/index.html",
"Wyoming" => "health.wyo.gov/publichealth/infectious-disease-epidemiology-unit/disease/novel-coronavirus/"
);
?>
<form action="" method="POST">
<select name="states" id="states">
<?php
foreach ($states as $array_key => $array_value) {
?>
<option value="https://<?php echo $array_value; ?>"><?php echo $array_key; ?></option>
<?php
} //end loop
?>
</select>
<input id="submit" type="submit" name="submit" value="Go">
</form>
<?php
if(isset($_POST['submit'])) {
$option = $_POST['states'];
header("Location: " . $option);
}
?>
</body>
</html>
Заранее спасибо.