<?php

// Yahoo Yql Winter Olympics Search Tutorial - RJM Programming - 2014
// {"year":"1924","city":"Chamonix","sport":"Skating","discipline":"Figure skating","country":"AUT","event":"pairs","gender":"X","type":"Gold"},

//Year,City,Sport,Discipline,NOC,Event,Event gender,Medal
//year,city,sport,discipline,country,event,gender,type
//1924,Chamonix,Skating,Figure skating,AUT,individual,M,Silver
//1924,Chamonix,Skating,Figure skating,AUT,individual,W,Gold

// Thanks to https://egovstandards.gov.in/sites/default/files/code-directories/xml/CD02.01.countrycode.xml
$ccodelist = "
<Country_2011>

<Country>
<Country_Name_in_English>DENMARK</Country_Name_in_English>
<Country_Short_Name_Code>DEN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CROATIA</Country_Name_in_English>
<Country_Short_Name_Code>CRO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LATVIA</Country_Name_in_English>
<Country_Short_Name_Code>LAT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BULGARIA</Country_Name_in_English>
<Country_Short_Name_Code>BUL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SLOVAKIA</Country_Name_in_English>
<Country_Short_Name_Code>SLO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>YUGOSLAVIA</Country_Name_in_English>
<Country_Short_Name_Code>YUG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>EAST GERMANY</Country_Name_in_English>
<Country_Short_Name_Code>GDR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LIECHTENSTEIN</Country_Name_in_English>
<Country_Short_Name_Code>LIE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UNIFIED TEAM AT OLYMPICS</Country_Name_in_English>
<Country_Short_Name_Code>EUN</Country_Short_Name_Code>
</Country>


<Country>
<Country_Name_in_English>CZECHOSLOVAKIA</Country_Name_in_English>
<Country_Short_Name_Code>TCH</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>RUSSIA</Country_Name_in_English>
<Country_Short_Name_Code>URS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>WEST GERMANY</Country_Name_in_English>
<Country_Short_Name_Code>FRG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SWITZERLAND</Country_Name_in_English>
<Country_Short_Name_Code>SUI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NETHERLANDS</Country_Name_in_English>
<Country_Short_Name_Code>NED</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GERMANY</Country_Name_in_English>
<Country_Short_Name_Code>GER</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UNITED STATES OF AMERICA</Country_Name_in_English>
<Country_Short_Name_Code>EUA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>AFGHANISTAN</Country_Name_in_English>
<Country_Short_Name_Code>AFG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ALBANIA</Country_Name_in_English>
<Country_Short_Name_Code>ALB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ALGERIA</Country_Name_in_English>
<Country_Short_Name_Code>DZA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ANDORRA</Country_Name_in_English>
<Country_Short_Name_Code>AND</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ANGOLA</Country_Name_in_English>
<Country_Short_Name_Code>AGO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ANTIGUA AND BARBUDA</Country_Name_in_English>
<Country_Short_Name_Code>ATG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ARGENTINA</Country_Name_in_English>
<Country_Short_Name_Code>ARG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ARMENIA</Country_Name_in_English>
<Country_Short_Name_Code>ARM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>AUSTRALIA</Country_Name_in_English>
<Country_Short_Name_Code>AUS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>AUSTRIA</Country_Name_in_English>
<Country_Short_Name_Code>AUT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>AZERBAIJAN</Country_Name_in_English>
<Country_Short_Name_Code>AZE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BAHAMAS</Country_Name_in_English>
<Country_Short_Name_Code>BHS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BAHRAIN</Country_Name_in_English>
<Country_Short_Name_Code>BHR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BANGLADESH</Country_Name_in_English>
<Country_Short_Name_Code>BGD</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BARBADOS</Country_Name_in_English>
<Country_Short_Name_Code>BRB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BELARUS</Country_Name_in_English>
<Country_Short_Name_Code>BLR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BELGIUM</Country_Name_in_English>
<Country_Short_Name_Code>BEL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BELIZE</Country_Name_in_English>
<Country_Short_Name_Code>BLZ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BENIN</Country_Name_in_English>
<Country_Short_Name_Code>BEN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BHUTAN</Country_Name_in_English>
<Country_Short_Name_Code>BTN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BOLIVIA</Country_Name_in_English>
<Country_Short_Name_Code>BOL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BOSNIA AND HERZEGOVINA</Country_Name_in_English>
<Country_Short_Name_Code>BIH</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BOTSWANA</Country_Name_in_English>
<Country_Short_Name_Code>BWA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BRAZIL</Country_Name_in_English>
<Country_Short_Name_Code>BRA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BULGARIA</Country_Name_in_English>
<Country_Short_Name_Code>BGR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BURKINA FASO</Country_Name_in_English>
<Country_Short_Name_Code>BFA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>BURUNDI</Country_Name_in_English>
<Country_Short_Name_Code>BDI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CAMBODIA</Country_Name_in_English>
<Country_Short_Name_Code>KHM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CAMEROON</Country_Name_in_English>
<Country_Short_Name_Code>CMR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CANADA</Country_Name_in_English>
<Country_Short_Name_Code>CAN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CAPE VERDE</Country_Name_in_English>
<Country_Short_Name_Code>CPV</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CENTRAL AFRICAN REP</Country_Name_in_English>
<Country_Short_Name_Code>CAF</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CHAD</Country_Name_in_English>
<Country_Short_Name_Code>TCD</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CHILE</Country_Name_in_English>
<Country_Short_Name_Code>CHL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CHINA</Country_Name_in_English>
<Country_Short_Name_Code>CHN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>COLOMBIA</Country_Name_in_English>
<Country_Short_Name_Code>COL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>COMOROS</Country_Name_in_English>
<Country_Short_Name_Code>COM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CONGO</Country_Name_in_English>
<Country_Short_Name_Code>COG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>COOK ISLANDS</Country_Name_in_English>
<Country_Short_Name_Code>COK</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>COSTA RICA</Country_Name_in_English>
<Country_Short_Name_Code>CRI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CÔTE D'IVOIRE</Country_Name_in_English>
<Country_Short_Name_Code>CIV</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CROATIA</Country_Name_in_English>
<Country_Short_Name_Code>HRV</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CUBA</Country_Name_in_English>
<Country_Short_Name_Code>CUB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CYPRUS</Country_Name_in_English>
<Country_Short_Name_Code>CYP</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>CZECH REP</Country_Name_in_English>
<Country_Short_Name_Code>CZE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>DEM PEOPLE'S REP OF KOREA</Country_Name_in_English>
<Country_Short_Name_Code>PRK</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>DEM REP OF THE CONGO</Country_Name_in_English>
<Country_Short_Name_Code>COD</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>DENMARK</Country_Name_in_English>
<Country_Short_Name_Code>DNK</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>DJIBOUTI</Country_Name_in_English>
<Country_Short_Name_Code>DJI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>DOMINICA</Country_Name_in_English>
<Country_Short_Name_Code>DMA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>DOMINICAN REP</Country_Name_in_English>
<Country_Short_Name_Code>DOM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ECUADOR</Country_Name_in_English>
<Country_Short_Name_Code>ECU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>EGYPT</Country_Name_in_English>
<Country_Short_Name_Code>EGY</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>EL SALVADOR</Country_Name_in_English>
<Country_Short_Name_Code>SLV</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>EQUATORIAL GUINEA</Country_Name_in_English>
<Country_Short_Name_Code>GNQ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ERITREA</Country_Name_in_English>
<Country_Short_Name_Code>ERI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ESTONIA</Country_Name_in_English>
<Country_Short_Name_Code>EST</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ETHIOPIA</Country_Name_in_English>
<Country_Short_Name_Code>ETH</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>FAROE ISLANDS</Country_Name_in_English>
<Country_Short_Name_Code>FRO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>FIJI</Country_Name_in_English>
<Country_Short_Name_Code>FJI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>FINLAND</Country_Name_in_English>
<Country_Short_Name_Code>FIN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>FRANCE</Country_Name_in_English>
<Country_Short_Name_Code>FRA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GABON</Country_Name_in_English>
<Country_Short_Name_Code>GAB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GAMBIA</Country_Name_in_English>
<Country_Short_Name_Code>GMB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GEORGIA</Country_Name_in_English>
<Country_Short_Name_Code>GEO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GERMANY</Country_Name_in_English>
<Country_Short_Name_Code>DEU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GHANA</Country_Name_in_English>
<Country_Short_Name_Code>GHA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GREECE</Country_Name_in_English>
<Country_Short_Name_Code>GRC</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GRENADA</Country_Name_in_English>
<Country_Short_Name_Code>GRD</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GUATEMALA</Country_Name_in_English>
<Country_Short_Name_Code>GTM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GUINEA</Country_Name_in_English>
<Country_Short_Name_Code>GIN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GUINEA-BISSAU</Country_Name_in_English>
<Country_Short_Name_Code>GNB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>GUYANA</Country_Name_in_English>
<Country_Short_Name_Code>GUY</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>HAITI</Country_Name_in_English>
<Country_Short_Name_Code>HTI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>HONDURAS</Country_Name_in_English>
<Country_Short_Name_Code>HND</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>HUNGARY</Country_Name_in_English>
<Country_Short_Name_Code>HUN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ICELAND</Country_Name_in_English>
<Country_Short_Name_Code>ISL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>INDIA</Country_Name_in_English>
<Country_Short_Name_Code>IND</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>INDONESIA</Country_Name_in_English>
<Country_Short_Name_Code>IDN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>IRAN (ISLAMIC REP OF)</Country_Name_in_English>
<Country_Short_Name_Code>IRN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>IRAQ</Country_Name_in_English>
<Country_Short_Name_Code>IRQ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>IRELAND</Country_Name_in_English>
<Country_Short_Name_Code>IRL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ISRAEL</Country_Name_in_English>
<Country_Short_Name_Code>ISR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ITALY</Country_Name_in_English>
<Country_Short_Name_Code>ITA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>JAMAICA</Country_Name_in_English>
<Country_Short_Name_Code>JAM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>JAPAN</Country_Name_in_English>
<Country_Short_Name_Code>JPN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>JORDAN</Country_Name_in_English>
<Country_Short_Name_Code>JOR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>KAZAKHSTAN</Country_Name_in_English>
<Country_Short_Name_Code>KAZ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>KENYA</Country_Name_in_English>
<Country_Short_Name_Code>KEN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>KIRIBATI</Country_Name_in_English>
<Country_Short_Name_Code>KIR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>KUWAIT</Country_Name_in_English>
<Country_Short_Name_Code>KWT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>KYRGYZSTAN</Country_Name_in_English>
<Country_Short_Name_Code>KGZ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LAO PEOPLE'S DEM REP</Country_Name_in_English>
<Country_Short_Name_Code>LAO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LATVIA</Country_Name_in_English>
<Country_Short_Name_Code>LVA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LEBANON</Country_Name_in_English>
<Country_Short_Name_Code>LBN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LESOTHO</Country_Name_in_English>
<Country_Short_Name_Code>LSO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LIBERIA</Country_Name_in_English>
<Country_Short_Name_Code>LBR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LIBYA</Country_Name_in_English>
<Country_Short_Name_Code>LBY</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LITHUANIA</Country_Name_in_English>
<Country_Short_Name_Code>LTU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>LUXEMBOURG</Country_Name_in_English>
<Country_Short_Name_Code>LUX</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MADAGASCAR</Country_Name_in_English>
<Country_Short_Name_Code>MDG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MALAWI</Country_Name_in_English>
<Country_Short_Name_Code>MWI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MALAYSIA</Country_Name_in_English>
<Country_Short_Name_Code>MYS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MALDIVES</Country_Name_in_English>
<Country_Short_Name_Code>MDV</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MALI</Country_Name_in_English>
<Country_Short_Name_Code>MLI</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MALTA</Country_Name_in_English>
<Country_Short_Name_Code>MLT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MARSHALL ISLANDS</Country_Name_in_English>
<Country_Short_Name_Code>MHL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MAURITANIA</Country_Name_in_English>
<Country_Short_Name_Code>MRT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MAURITIUS</Country_Name_in_English>
<Country_Short_Name_Code>MUS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MEXICO</Country_Name_in_English>
<Country_Short_Name_Code>MEX</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MICRONESIA (FED STATES OF)</Country_Name_in_English>
<Country_Short_Name_Code>FSM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MONACO</Country_Name_in_English>
<Country_Short_Name_Code>MCO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MONGOLIA</Country_Name_in_English>
<Country_Short_Name_Code>MNG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MONTENEGRO</Country_Name_in_English>
<Country_Short_Name_Code>MNE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MOROCCO</Country_Name_in_English>
<Country_Short_Name_Code>MAR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MOZAMBIQUE</Country_Name_in_English>
<Country_Short_Name_Code>MOZ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>MYANMAR</Country_Name_in_English>
<Country_Short_Name_Code>MMR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NAMIBIA</Country_Name_in_English>
<Country_Short_Name_Code>NAM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NAURU</Country_Name_in_English>
<Country_Short_Name_Code>NRU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NEPAL</Country_Name_in_English>
<Country_Short_Name_Code>NPL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NETHERLANDS</Country_Name_in_English>
<Country_Short_Name_Code>NLD</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NEW ZEALAND</Country_Name_in_English>
<Country_Short_Name_Code>NZL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NICARAGUA</Country_Name_in_English>
<Country_Short_Name_Code>NIC</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NIGER</Country_Name_in_English>
<Country_Short_Name_Code>NER</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NIGERIA</Country_Name_in_English>
<Country_Short_Name_Code>NGA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NIUE</Country_Name_in_English>
<Country_Short_Name_Code>NIU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>NORWAY</Country_Name_in_English>
<Country_Short_Name_Code>NOR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>OMAN</Country_Name_in_English>
<Country_Short_Name_Code>OMN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PAKISTAN</Country_Name_in_English>
<Country_Short_Name_Code>PAK</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PALAU</Country_Name_in_English>
<Country_Short_Name_Code>PLW</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PANAMA</Country_Name_in_English>
<Country_Short_Name_Code>PAN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PAPUA NEW GUINEA</Country_Name_in_English>
<Country_Short_Name_Code>PNG</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PARAGUAY</Country_Name_in_English>
<Country_Short_Name_Code>PRY</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PERU</Country_Name_in_English>
<Country_Short_Name_Code>PER</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PHILIPPINES</Country_Name_in_English>
<Country_Short_Name_Code>PHL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>POLAND</Country_Name_in_English>
<Country_Short_Name_Code>POL</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>PORTUGAL</Country_Name_in_English>
<Country_Short_Name_Code>PRT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>QATAR</Country_Name_in_English>
<Country_Short_Name_Code>QAT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>REP OF KOREA</Country_Name_in_English>
<Country_Short_Name_Code>KOR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>REP OF MOLDOVA</Country_Name_in_English>
<Country_Short_Name_Code>MDA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ROMANIA</Country_Name_in_English>
<Country_Short_Name_Code>ROU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>RUSSIAN FEDERATION</Country_Name_in_English>
<Country_Short_Name_Code>RUS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>RWANDA</Country_Name_in_English>
<Country_Short_Name_Code>RWA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAINT KITTS AND NEVIS</Country_Name_in_English>
<Country_Short_Name_Code>KNA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAINT LUCIA</Country_Name_in_English>
<Country_Short_Name_Code>LCA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAINT VINCENT AND THE GRENADINES</Country_Name_in_English>
<Country_Short_Name_Code>VCT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAMOA</Country_Name_in_English>
<Country_Short_Name_Code>WSM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAN MARINO</Country_Name_in_English>
<Country_Short_Name_Code>SMR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAO TOME AND PRINCIPE</Country_Name_in_English>
<Country_Short_Name_Code>STP</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SAUDI ARABIA</Country_Name_in_English>
<Country_Short_Name_Code>SAU</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SENEGAL</Country_Name_in_English>
<Country_Short_Name_Code>SEN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SERBIA</Country_Name_in_English>
<Country_Short_Name_Code>SRB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SEYCHELLES</Country_Name_in_English>
<Country_Short_Name_Code>SYC</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SIERRA LEONE</Country_Name_in_English>
<Country_Short_Name_Code>SLE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SLOVAKIA</Country_Name_in_English>
<Country_Short_Name_Code>SVK</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SLOVENIA</Country_Name_in_English>
<Country_Short_Name_Code>SVN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SOLOMON ISLANDS</Country_Name_in_English>
<Country_Short_Name_Code>SLB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SOMALIA</Country_Name_in_English>
<Country_Short_Name_Code>SOM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SOUTH AFRICA</Country_Name_in_English>
<Country_Short_Name_Code>ZAF</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SPAIN</Country_Name_in_English>
<Country_Short_Name_Code>ESP</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SRI LANKA</Country_Name_in_English>
<Country_Short_Name_Code>LKA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SUDAN</Country_Name_in_English>
<Country_Short_Name_Code>SDN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SURINAME</Country_Name_in_English>
<Country_Short_Name_Code>SUR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SWAZILAND</Country_Name_in_English>
<Country_Short_Name_Code>SWZ</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SWEDEN</Country_Name_in_English>
<Country_Short_Name_Code>SWE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SWITZERLAND</Country_Name_in_English>
<Country_Short_Name_Code>CHE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>SYRIAN ARAB REP</Country_Name_in_English>
<Country_Short_Name_Code>SYR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TAJIKISTAN</Country_Name_in_English>
<Country_Short_Name_Code>TJK</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TFYR OF MACEDONIA</Country_Name_in_English>
<Country_Short_Name_Code>MKD</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>THAILAND</Country_Name_in_English>
<Country_Short_Name_Code>THA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TIMOR-LESTE</Country_Name_in_English>
<Country_Short_Name_Code>TLS</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TOGO</Country_Name_in_English>
<Country_Short_Name_Code>TGO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TONGA</Country_Name_in_English>
<Country_Short_Name_Code>TON</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TRINIDAD AND TOBAGO</Country_Name_in_English>
<Country_Short_Name_Code>TTO</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TUNISIA</Country_Name_in_English>
<Country_Short_Name_Code>TUN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TURKEY</Country_Name_in_English>
<Country_Short_Name_Code>TUR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TURKMENISTAN</Country_Name_in_English>
<Country_Short_Name_Code>TKM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>TUVALU</Country_Name_in_English>
<Country_Short_Name_Code>TUV</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UGANDA</Country_Name_in_English>
<Country_Short_Name_Code>UGA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UKRAINE</Country_Name_in_English>
<Country_Short_Name_Code>UKR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UNITED ARAB EMIRATES</Country_Name_in_English>
<Country_Short_Name_Code>ARE</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UNITED KINGDOM</Country_Name_in_English>
<Country_Short_Name_Code>GBR</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UNITED REP OF TANZANIA</Country_Name_in_English>
<Country_Short_Name_Code>TZA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UNITED STATES OF AMERICA</Country_Name_in_English>
<Country_Short_Name_Code>USA</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>URUGUAY</Country_Name_in_English>
<Country_Short_Name_Code>URY</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>UZBEKISTAN</Country_Name_in_English>
<Country_Short_Name_Code>UZB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>VANUATU</Country_Name_in_English>
<Country_Short_Name_Code>VUT</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>VENEZUELA (BOLIVARIAN REP OF)</Country_Name_in_English>
<Country_Short_Name_Code>VEN</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>VIET NAM</Country_Name_in_English>
<Country_Short_Name_Code>VNM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>YEMEN</Country_Name_in_English>
<Country_Short_Name_Code>YEM</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ZAMBIA</Country_Name_in_English>
<Country_Short_Name_Code>ZMB</Country_Short_Name_Code>
</Country>
<Country>
<Country_Name_in_English>ZIMBABWE</Country_Name_in_English>
<Country_Short_Name_Code>ZWE</Country_Short_Name_Code>
</Country>
</Country_2011>
";

 $yeararr = array();
 $cityarr = array();
 $sportarr = array();
 $disciplinearr = array();
 $countrycodearr = array();
 $countryarr = array();
 $eventarr = array();
 $genderarr = array();
 $typearr = array();
 $woarr = array();
 
 $things = array("year", "city", "sport", "discipline", "country", "event", "gender", "type");


function codeincountryout($cisin) {
  global $ccodelist;
  $countryout = $cisin;
  $xout = explode("<Country_Short_Name_Code>" . $cisin . "<", $ccodelist);
  if (sizeof($xout) == 2) {
    $xoutagain = explode(">", $xout[0]);
    $countryout = str_replace("</Country_Name_in_English", "", $xoutagain[sizeof($xoutagain) - 2]);
  } else {
    $xout = explode("<Country_Name_in_English>" . $cisin . "<", $ccodelist);
    if (sizeof($xout) == 2) {
     $xoutagain = explode(">", $xout[1]);
     $countryout = str_replace("</Country_Short_Name_Code", "", $xoutagain[2]);
    }
  }
  return $countryout;
}

function populate($thecont) {
 $offset = 0;
 global $po, $tot, $woarr, $yeararr, $cityarr, $sportarr, $disciplinearr, $countrycodearr, $countryarr, $eventarr, $genderarr, $typearr;
 global $yearlist, $citylist, $sportlist, $disciplinelist, $countrycodelist, $countrylist, $eventlist, $genderlist, $typelist, $wolist;
 $lines = explode("\n", $thecont);
 for ($i=0; $i<sizeof($lines); $i++) {
   $fields = explode(",", $lines[$i]);
   if (sizeof($fields) < 7) {
     $woarr[$i] = "";
     $offset = $offset + 1;
   } else {
   if (substr($fields[0] . " ",0,1) >= "0" && substr($fields[0] . " ",0,1) <= "9") {
     if (strlen($po) > 0 && strpos($po, ",") !== false && strpos($lines[$i], $po) !== false) $po = ($i + 0 - $offset);

     $woarr[($i + 0 - $offset)] = $lines[$i];

     if (strpos($yearlist, "'" . $fields[0] . "'") === false) $yeararr[sizeof($yeararr)] = $fields[0];
     if (strpos($citylist, '"' . $fields[1] . '"') === false) $cityarr[sizeof($cityarr)] = $fields[1];
     if (strpos($sportlist, "'" . $fields[2] . "'") === false) $sportarr[sizeof($sportarr)] = $fields[2];
     if (strpos($disciplinelist, "'" . $fields[3] . "'") === false) $disciplinearr[sizeof($disciplinearr)] = $fields[3];
     if (strpos($countrycodelist, '"' . str_replace("EUA", "USA", $fields[4]) . '"') === false) $countrycodearr[sizeof($countrycodearr)] = str_replace("EUA", "USA", $fields[4]);
     if (strpos($countrylist, '"' . str_replace("EUA", "USA", $fields[4]) . '"') === false) $countryarr[sizeof($countryarr)] = codeincountryout(str_replace("EUA", "USA", $fields[4]));
     if (strlen($fields[6]) > 1) {
     if (strpos($eventlist, "'" . $fields[5] . "," . $fields[6] . "'") === false) $eventarr[sizeof($eventarr)] = $fields[5] . "," . $fields[6];
     if (strpos($genderlist, "'" . $fields[7] . "'") === false) $genderarr[sizeof($genderarr)] =  $fields[7];
     if (strpos($typelist, "'" . $fields[8] . "'") === false) $typearr[sizeof($typearr)] = $fields[8];
     } else {
     if (strpos($eventlist, "'" . $fields[5] . "'") === false) $eventarr[sizeof($eventarr)] =  $fields[5];
     if (strpos($genderlist, "'" . $fields[6] . "'") === false) $genderarr[sizeof($genderarr)] =  $fields[6];
     if (strpos($typelist, "'" . $fields[7] . "'") === false) $typearr[sizeof($typearr)] =  $fields[7];
     }


     if (strpos($yearlist, "'" . $fields[0] . "'") === false) $yearlist .= "<option value='" . $fields[0] . "'>" . $fields[0] . "</option>";
     if (strpos($citylist, '"' . $fields[1] . '"') === false) $citylist .= '<option value="' . $fields[1] . '">' . $fields[1] . '</option>';
     if (strpos($sportlist, "'" . $fields[2] . "'") === false) $sportlist .= "<option value='" . $fields[2] . "'>" . $fields[2] . "</option>";
     if (strpos($disciplinelist, "'" . $fields[3] . "'") === false) $disciplinelist .= "<option value='" . $fields[3] . "'>" . $fields[3] . "</option>";
     if (strpos($countrycodelist, '"' . str_replace("EUA", "USA", $fields[4]) . '"') === false) $countrycodelist .= '<option value="' . str_replace("EUA", "USA", $fields[4]) . '">' . str_replace("EUA", "USA", $fields[4]) . "</option>";
     if (strpos($countrylist, '"' . str_replace("EUA", "USA", $fields[4]) . '"') === false) $countrylist .= '<option value="' . str_replace("EUA", "USA", $fields[4]) . '">' . codeincountryout(str_replace("EUA", "USA", $fields[4])) . "</option>";
     if (strlen($fields[6]) > 1) {
     if (strpos($eventlist, "'" . $fields[5] . "+" . $fields[6] . "'") === false) $eventlist .= "<option value='" . $fields[5] . "+" . $fields[6] . "'>" . $fields[5] . "</option>";
     if (strpos($genderlist, "'" . $fields[7] . "'") === false) $genderlist .= "<option value='" . $fields[7] . "'>" . $fields[7] . "</option>";
     if (strpos($typelist, "'" . $fields[8] . "'") === false) $typelist .= "<option value='" . $fields[8] . "'>" . $fields[8] . "</option>";
     } else {
     if (strpos($eventlist, "'" . $fields[5] . "'") === false) $eventlist .= "<option value='" . $fields[5] . "'>" . $fields[5] . "</option>";
     if (strpos($genderlist, "'" . $fields[6] . "'") === false) $genderlist .= "<option value='" . $fields[6] . "'>" . $fields[6] . "</option>";
     if (strpos($typelist, "'" . $fields[7] . "'") === false) $typelist .= "<option value='" . $fields[7] . "'>" . $fields[7] . "</option>";
     }

     $wolist .= "<option value='" . $lines[$i] . "'>" . ($i + 0 - $offset) . "</option>";
     $tot = ($i + 0 - $offset);
   }
   }
 }

}

$tot = 0;
$po = "";

if (!isset($_POST['stage'])) { // first off
 if (isset($_GET['pickone'])) {
   $po = urldecode($_GET['pickone']);
 }
 $yearlist = "<div align='center' id='dparts' style='display:none;'><select name='yearsel' id='yearsel'><option value=''>Please select Year below ...</option>";
 $citylist = "<select name='citysel' id='citysel'><option value=''>Select City below ...</option>";
 $sportlist = "<select name='sportsel' id='sportsel'><option value=''>Select Sport below ...</option>";
 $disciplinelist = "<select name='disciplinesel' id='disciplinesel'><option value=''>Select Discipline below ...</option>";
 $countrycodelist = "<select style='display:none;' name='countrycodesel' id='countrycodesel'><option value=''>Select Country Code below ...</option>";
 $countrylist = "<select name='countrysel' id='countrysel'><option value=''>Select Country below ...</option>";
 $eventlist = "<select name='eventsel' id='eventsel'><option value=''>Select Event below ...</option>";
 $genderlist = "<select name='gendersel' id='gendersel'><option value=''>Select Gender below ...</option>";
 $typelist = "<select name='typesel' id='typesel'><option value=''>Select Medal Type below ...</option><option value='Gold'>Gold</option><option value='Silver'>Silver</option><option value='Bronze'>Bronze</option>";
 $wolist = "<select onchange='document.getElementById(\"submit\").click();' name='wosel' id='wosel' style='text-align:center;'><option value=''>Please select a secret Winter Olympic medal presentation number below ...</option>";
 $pageContent = file_get_contents("http://isithackday.com/medals.csv");
 $pageContent .= "\n2002,Salt Lake City,Skating,Short Track S.,AUS,1000m,M,Gold\n";
 $pageContent .= "\n2002,Salt Lake City,Skiing,Aerial Skiing,AUS,Aerials,W,Gold\n";
 populate($pageContent);
 $yearlist .= "</select>&nbsp;&nbsp;";
 $citylist .= "</select>&nbsp;&nbsp;";
 $sportlist .= "</select>&nbsp;&nbsp;";
 $disciplinelist .= "</select>&nbsp;&nbsp;";
 $countrycodelist .= "</select>";
 $countrylist .= "</select>&nbsp;&nbsp;";
 $eventlist .= "</select>&nbsp;&nbsp;";
 $genderlist .= "</select>&nbsp;&nbsp;";
 $typelist .= "</select></div>";
 $wolist .= "</select><br><br>";
 if (isset($_GET['score']) && isset($_GET['goes'])) {
 echo "<!doctype HTML><html><head><title>Winter Olympics Game ... Score: " . $_GET['score'] . " Goes: " . $_GET['goes'] . "</title><link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'></head><body align='center' style='background-color:lightgreen;'><h1 align='center'>Winter Olympics Game ... Score: " . $_POST['score'] . " Goes: " . $_POST['goes'] . "</h1><br><div align='center'>";
 } else {
 echo "<!doctype HTML><html><head><title>Winter Olympics Game</title><link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'></head><body align='center' style='background-color:yellow;'><h1 align='center'>Winter Olympics Game</h1><br><div align='center'>";
 }
 echo "<form action='./winter_olympics.php' method='POST'>\n";
 echo $wolist;
 echo $yearlist . $citylist . $sportlist . $disciplinelist . $eventlist . $countrycodelist . $countrylist . $genderlist . $typelist;
 echo "</div>";
 if (isset($_GET['score']) && isset($_GET['goes'])) {
 echo "<input type='hidden' id='score' name='score' value='" . $_GET['score'] . "' />";
 echo "<input type='hidden' id='goes' name='goes' value='" . $_GET['goes'] . "' />";
 } else {
 echo "<input type='hidden' id='score' name='score' value='0' />";
 echo "<input type='hidden' id='goes' name='goes' value='0' />";
 }
 echo "<input type='hidden' id='stage' name='stage' value='0' />";
 echo "<input type='submit' id='submit' name='submit' value='Answer' style='display:none;' />";
 echo "</form>";
 if ($po != "" || isset($_GET['pickone'])) {
   if ($po == "") {
     echo "\n<scr" . "ipt> document.getElementById('wosel').value = '" . $woarr[rand(1, $tot)] . "'; document.getElementById('submit').click(); </scr" . "ipt> ";
   } else {
     if (substr($po,0,1) >= "0" && substr($po,0,1) <= "9") {
       echo "\n<scr" . "ipt> document.getElementById('wosel').value = '" . $woarr[$po] . "'; document.getElementById('submit').click(); </scr" . "ipt> ";
     } else {
       echo "\n<scr" . "ipt> document.getElementById('wosel').value = '" . $woarr[rand(1, $tot)] . "'; document.getElementById('submit').click(); </scr" . "ipt> ";
     }
   }
 }
 //echo "<table><tr><td style='width:50%;'><iframe src='https://www.google.com.au/search?q=%22Winter+Olympics%22&biw=1280&bih=625&source=lnms&tbm=isch&sa=X&ei=mPFmVNriNqLXmgXxu4KoCQ&ved=0CAYQ_AUoAQ' title='Winter Olympics images'></iframe></td><td style='width:50%;'><iframe src='https://www.google.com.au/search?q=%22Winter+Olympics%22&biw=1280&bih=625&tbm=vid&source=lnms&sa=X&ei=pvFmVOLnGuSNmwWcuICYCg&ved=0CAkQ_AUoAg&dpr=1' title='Winter Olympics videos'></iframe></td></tr>";
 //echo "<tr><td colspan=2><iframe src='https://www.google.com.au/?gfe_rd=cr&ei=kPFmVIf7OMqN8QeXtIDQBw&gws_rd=ssl#q=%22Winter+Olympics%22' title='Winter Olympics'></iframe></td></tr></table>";
 echo "\n<scr" . "ipt> window.open('https://www.google.com.au/search?q=%22Winter+Olympics%22&biw=1280&bih=625&source=lnms&tbm=isch&sa=X&ei=mPFmVNriNqLXmgXxu4KoCQ&ved=0CAYQ_AUoAQ', '_blank', 'top=400,left=20,width=300,height=500');  window.open('https://www.google.com.au/search?q=%22Winter+Olympics%22&biw=1280&bih=625&tbm=vid&source=lnms&sa=X&ei=pvFmVOLnGuSNmwWcuICYCg&ved=0CAkQ_AUoAg&dpr=1', '_blank', 'top=400,left=320,width=300,height=500');   window.open('https://www.google.com.au/?gfe_rd=cr&ei=kPFmVIf7OMqN8QeXtIDQBw&gws_rd=ssl#q=%22Winter+Olympics%22', '_blank', 'top=400,left=620,width=900,height=500');  </scr" . "ipt>";
 echo "</body></html>";
 
} else if (isset($_POST['stage'])) {
 $yearlist = "<div align='center' id='dparts' style='display:inline;'>\n<select name='yearsel' id='yearsel'><option value=''>Please select Year below ...</option>";
 $citylist = "\n<select name='citysel' id='citysel'><option value=''>Select City below ...</option>";
 $sportlist = "\n<select name='sportsel' id='sportsel'><option value=''>Select Sport below ...</option>";
 $disciplinelist = "\n<select name='disciplinesel' id='disciplinesel'><option value=''>Select Discipline below ...</option>";
 $countrycodelist = "\n<select style='display:none;' name='countrycodesel' id='countrycodesel'><option value=''>Select Country Code below ...</option>";
 $countrylist = "\n<select name='countrysel' id='countrysel'><option value=''>Select Country below ...</option>";
 $eventlist = "\n<select name='eventsel' id='eventsel'><option value=''>Select Event below ...</option>";
 $genderlist = "\n<select name='gendersel' id='gendersel'><option value=''>Select Gender below ...</option>";
 $typelist = "\n<select name='typesel' id='typesel'><option value=''>Select Medal Type below ...</option><option value='Gold'>Gold</option><option value='Silver'>Silver</option><option value='Bronze'>Bronze</option>";
 $wolist = "<select onchange='location.href=\"./winter_olympics.php?score=" . $_POST['score'] . "&goes=" . $_POST['goes'] . "&pickone=\" + this.value;' name='wosel' id='wosel' style='text-align:center;background-color:orange;'><option value=''>Please select a secret Winter Olympic medal presentation number below ...</option>";
 $pageContent = file_get_contents("http://isithackday.com/medals.csv");
 $pageContent .= "\n2002,Salt Lake City,Skating,Short Track S.,AUS,1000m,M,Gold\n";
 $pageContent .= "\n2002,Salt Lake City,Skiing,Aerial Skiing,AUS,Aerials,W,Gold\n";
 populate($pageContent);
 $yearlist .= "</select>&nbsp;&nbsp;";
 $citylist .= "</select>&nbsp;&nbsp;";
 $sportlist .= "</select>&nbsp;&nbsp;";
 $disciplinelist .= "</select>&nbsp;&nbsp;";
 $countrycodelist .= "</select>";
 $countrylist .= "</select>&nbsp;&nbsp;";
 $eventlist .= "</select>&nbsp;&nbsp;";
 $genderlist .= "</select>&nbsp;&nbsp;";
 $typelist .= "</select></div>";
 $wolist .= "</select><br><br>";
 if ($_POST['stage'] == "0") {   // have selected from first dropdown but not answered yet
  echo "<!doctype HTML><html><head><title>Winter Olympics Game ... Score: " . $_POST['score'] . " Goes: " . $_POST['goes'] . "</title><link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'></head><body align='center' style='background-color:lightgreen;'><h1 align='center'>Winter Olympics Game ... Score: " . $_POST['score'] . " Goes: " . $_POST['goes'] . "</h1><br><div align='center'>";
  echo "<form action='./winter_olympics.php' method='POST'>\n";
  echo str_replace(urldecode($_POST['wosel']) . "'", urldecode($_POST['wosel']) . "' selected", $wolist);
  $ii = 0;
  $sij = ";";
  $ij = rand(0,7);
  $cols = explode(",", urldecode($_POST['wosel']));
  while ($ii < 5) {
     while (strpos($sij, $ij . ";") !== false) {
       $ij = rand(0,7);
     }
     $sij .= ($ij . ";");
     echo "<input type='hidden' id='" . $things[$ij] . "' value='" . $cols[$ij] . "' />";
     if ($ij == 1 || $ij == 4) {
     $xx = '$' . $things[$ij] . 'list = str_replace("<select ", "<select onchange=this.value=document.getElementById(' . "'" . $things[$ij] . "'" . ').value; style=background-color:orange; ", str_replace("' . $cols[$ij] . "'\"," . '"' . $cols[$ij] . "' selected" . '", $' . $things[$ij] . 'list));';
     $xxx = str_replace("~", "'", str_replace("'", '"', str_replace('"', "~", $xx)));
     //echo $xxx;
     eval($xxx);
     } else {
     //echo '<p>$' . $things[$ij] . 'list = str_replace("' . $cols[$ij] . "'\"," . '"' . $cols[$ij] . "' selected" . '", $' . $things[$ij] . 'list)</p><br>';
     eval('$' . $things[$ij] . 'list = str_replace("<select ", "<select onchange=this.value=document.getElementById(' . "'" . $things[$ij] . "'" . ').value; style=background-color:orange; ", str_replace("' . $cols[$ij] . "'\"," . '"' . $cols[$ij] . "' selected" . '", $' . $things[$ij] . 'list));');
     }
     $ii++;
     $ij = rand(0,7);
  }
  echo $yearlist . $citylist . $sportlist . $disciplinelist . $eventlist . $countrycodelist . $countrylist . $genderlist . $typelist;
  echo "</div>";
  echo "<input type='hidden' id='score' name='score' value='" . $_POST['score'] . "' />";
  echo "<input type='hidden' id='goes' name='goes' value='" . $_POST['goes'] . "' />";
  echo "<input type='hidden' id='stage' name='stage' value='1' />";
  echo "<br><br><div align='center'><input align='center' type='submit' id='submit' name='submit' value='Answer' style='display:block;' /></div>";
  echo "</form>";
  echo "</body></html>";
 } else {    // check answer
 
 $score = $_POST['score'];
 $goes = 1 + $_POST['goes'];

 $yearlist = "<div align='center' id='dparts' style='display:none;'><select name='yearsel' id='yearsel'><option value=''>Please select Year below ...</option>";
 $citylist = "<select name='citysel' id='citysel'><option value=''>Select City below ...</option>";
 $sportlist = "<select name='sportsel' id='sportsel'><option value=''>Select Sport below ...</option>";
 $disciplinelist = "<select name='disciplinesel' id='disciplinesel'><option value=''>Select Discipline below ...</option>";
 $countrycodelist = "<select style='display:none;' name='countrycodesel' id='countrycodesel'><option value=''>Select Country Code below ...</option>";
 $countrylist = "<select name='countrysel' id='countrysel'><option value=''>Select Country below ...</option>";
 $eventlist = "<select name='eventsel' id='eventsel'><option value=''>Select Event below ...</option>";
 $genderlist = "<select name='gendersel' id='gendersel'><option value=''>Select Gender below ...</option>";
 $typelist = "<select name='typesel' id='typesel'><option value=''>Select Medal Type below ...</option><option value='Gold'>Gold</option><option value='Silver'>Silver</option><option value='Bronze'>Bronze</option>";
 $wolist = "<select onchange='document.getElementById(\"submit\").click();' name='wosel' id='wosel' style='text-align:center;'><option value=''>Please select a secret Winter Olympic medal presentation number below ...</option>";
 $pageContent = file_get_contents("http://isithackday.com/medals.csv");
 $pageContent .= "\n2002,Salt Lake City,Skating,Short Track S.,AUS,1000m,M,Gold\n";
 $pageContent .= "\n2002,Salt Lake City,Skiing,Aerial Skiing,AUS,Aerials,W,Gold\n";
 populate($pageContent);
 $yearlist .= "</select>&nbsp;&nbsp;";
 $citylist .= "</select>&nbsp;&nbsp;";
 $sportlist .= "</select>&nbsp;&nbsp;";
 $disciplinelist .= "</select>&nbsp;&nbsp;";
 $countrycodelist .= "</select>";
 $countrylist .= "</select>&nbsp;&nbsp;";
 $eventlist .= "</select>&nbsp;&nbsp;";
 $genderlist .= "</select>&nbsp;&nbsp;";
 $typelist .= "</select></div>";
 $wolist .= "</select><br><br>";
 
 $xurl = '#';
 $aurl = "https://www.google.com.au/?gfe_rd=cr&ei=GthlVPz3O8yN8QeBsoHQCA&gws_rd=ssl#q=" . urlencode($_POST['wosel']);
 if (urldecode($_POST['wosel']) == urldecode($_POST['yearsel'] . ',' . $_POST['citysel'] . ',' . $_POST['sportsel'] . ',' . $_POST['disciplinesel'] . ',' . $_POST['countrysel'] . ',' . $_POST['eventsel'] . ',' . $_POST['gendersel'] . ',' . $_POST['typesel'])) {
   $score = 1 + $_POST['score'];
   echo "<!doctype HTML><html><head><title>Winter Olympics Game ... Score: " . $score . " Goes: " . $goes . "</title><link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'></head><body align='center' style='background-color:yellow;'><h1 align='center'>Winter Olympics Game ... Score: " . $score . " Goes: " . $goes . "</h1><br><div align='center'>";
   echo "<br><br><p>Great work ... optional research can start <a href='" . $xurl . "' onclick='window.open(\"" . $aurl . "\",\"_blank\",\"top=20,left=20,width=600,height=400\");' title='Research'>here</a></p><br><br>";
 } else if (strpos($wolist, urldecode($_POST['yearsel'] . ',' . $_POST['citysel'] . ',' . $_POST['sportsel'] . ',' . $_POST['disciplinesel'] . ',' . $_POST['countrysel'] . ',' . $_POST['eventsel'] . ',' . $_POST['gendersel'] . ',' . $_POST['typesel'])) !== false) {
   $score = 1 + $_POST['score'];
   $aurl = "https://www.google.com.au/?gfe_rd=cr&ei=GthlVPz3O8yN8QeBsoHQCA&gws_rd=ssl#q=" . urldecode($_POST['yearsel'] . ',' . $_POST['citysel'] . ',' . $_POST['sportsel'] . ',' . $_POST['disciplinesel'] . ',' . $_POST['countrysel'] . ',' . $_POST['eventsel'] . ',' . $_POST['gendersel'] . ',' . $_POST['typesel']);
   echo "<!doctype HTML><html><head><title>Winter Olympics Game ... Score: " . $score . " Goes: " . $goes . "</title><link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'></head><body align='center' style='background-color:yellow;'><h1 align='center'>Winter Olympics Game ... Score: " . $score . " Goes: " . $goes . "</h1><br><div align='center'>";
   echo "<br><br><p>Great work ... optional research can start <a href='" . $xurl . "' onclick='window.open(\"" . $aurl . "\",\"_blank\",\"top=20,left=20,width=600,height=400\");' title='Research'>here</a></p><br><br>";
 } else {
   echo "<!doctype HTML><html><head><title>Winter Olympics Game ... Score: " . $score . " Goes: " . $goes . "</title><link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'></head><body align='center' style='background-color:yellow;'><h1 align='center'>Winter Olympics Game ... Score: " . $score . " Goes: " . $goes . "</h1><br><div align='center'>";
   echo "<br><br><p>Sorry ... you said " . urldecode($_POST['yearsel'] . ',' . $_POST['citysel'] . ',' . $_POST['sportsel'] . ',' . $_POST['disciplinesel'] . ',' . $_POST['countrysel'] . ',' . $_POST['eventsel'] . ',' . $_POST['gendersel'] . ',' . $_POST['typesel']) . "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ... but answer is " . $_POST['wosel'] . " ... optional research can start <a href='" . $xurl . "' onclick='window.open(\"" . $aurl . "\",\"_blank\",\"top=20,left=20,width=600,height=400\");' title='Research'>here</a></p><br><br>";
 }

 echo "<form action='./winter_olympics.php' method='POST'>\n";
 echo $wolist;
 echo $yearlist . $citylist . $sportlist . $disciplinelist . $eventlist . $countrycodelist . $countrylist . $genderlist . $typelist;
 echo "</div>";
 echo "<input type='hidden' id='score' name='score' value='" . $score . "' />";
 echo "<input type='hidden' id='goes' name='goes' value='" . $goes . "' />";
 echo "<input type='hidden' id='stage' name='stage' value='0' />";
 echo "<input type='submit' id='submit' name='submit' value='Answer' style='display:none;' />";
 echo "</form>";
 echo "</body></html>";



 }
 
 
}
?> 

