1) { $rest = str_replace("~", "", str_replace("," . $xrest[(sizeof($xrest) - 1)] . "~", "", ($pgm . "~"))); $pgm = $xrest[(sizeof($xrest) - 1)]; } if (str_replace(".", "", $pgm) != $pgm) { $dollars = "US\$"; if ($pgm == "NY.GNP.PCAP.CD") $alttitle = "Worldbank Data ... GNI per capita, Atlas method (current US\$)"; if ($pgm == "NY.GNP.PCAP.KD") $alttitle = "Worldbank Data ... GNI per capita (constant 2005 US\$)"; if ($pgm == "NY.GDP.PCAP.KD") $alttitle = "Worldbank Data ... GDP per capita (constant 2005 US\$)"; if ($pgm == "NY.GDP.PCAP.CD") $alttitle = "Worldbank Data ... GDP per capita, Atlas method (current US\$)"; $altsuffix = str_replace(" ", "%20", " AND indicator_id = '" . $pgm . "' "); } if ($pgm == "3539" || $pgm == "1519") { $dollars = "Years"; $altsuffix = str_replace(" ", "%20", " AND indicator_id = 'BAR.PRM.SCHL." . $pgm . "' "); if ($pgm == "1519") { $alttitle = "Worldbank Data ... Average Years of Primary Schooling, 15-19, Total"; } else if ($pgm == "3539") { $alttitle = "Worldbank Data ... Average Years of Primary Schooling, 35-39, Total"; } } } $alttsuff = "data"; $altthing = "data"; $altthingtwo = "results->data"; $suff = "countries"; $yesh1 = " "; $thing = "country"; $thw = ""; $thingtwo = "results"; $suffix = ""; $selname = ""; $ititle = " ... Worldbank Countries"; if (isset($_POST['noh1'])) $yesh1 = ""; if (isset($_GET['noh1'])) $yesh1 = ""; if (isset($_POST['selname'])) $selname = str_replace(" ","%20",$_POST['selname']); if (isset($_GET['selname'])) $selname = str_replace(" ","%20",$_GET['selname']); if (isset($_POST['mode'])) $suffix = str_replace(" ","%20", $altsuffix); if (isset($_GET['mode'])) $suffix = str_replace(" ","%20", $altsuffix); if ($suffix != "") $suff = $alttsuff; if ($suffix != "") $ititle = $alttitle; if ($suffix != "") $thing = $altthing; if ($suffix != "") $thingtwo = $altthingtwo; $bcolours = array("white", "pink", "aqua", "lime", "silver", "lightyellow", "cyan", "fuchsia", "orange", "lightblue", "lightgreen", "lightgray"); $bits = "margin-top:-390px;"; if ($selname != "") { date_default_timezone_set('London/England'); $date = date('d/m/Y h:i:s a', time()) . " GMT"; $pageContent = file_get_contents("http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20worldbank." . $suff . "%20WHERE%20country_id%20%3D%20'" . $selname . "'%20" . $suffix . "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback="); if ($ititle == $alttitle) { $thw = " style='height:" . (1200 + sizeof($xrest) * 500) . "px;overflow:scroll;background-color:pink;' "; $bits = "margin-top:-" . (440 + 100 * sizeof($xrest)) . "px;"; $postsuff = explode(',"content":"', $pageContent); if (sizeof($postsuff) > 1) { $ecountry = explode('"', $postsuff[sizeof($postsuff) - 1]); $clist = explode(",", $alttitle); $firstbit = $clist[0]; $lastbit = str_replace($clist[0], "", $alttitle); if (strlen($lastbit) > 0) $lastbit = str_replace(",,", ",", "," . $lastbit); $ititle = $firstbit . " in " . str_replace("+", " ", str_replace("+d%27", " d", urlencode($ecountry[0]))) . $lastbit; $date = ""; } } //echo $pageContent; $json_output = json_decode($pageContent); // Confirm that results were returned before parsing // if (!is_null(eval("$" . "json_output->query->results->" . $thing))) { //echo "yessir"; $stuff = "\n"; $pstuff = ""; $prebits = " colspan=1 align='center'>"; if (isset($_GET['andthen'])) $bits = ""; if (isset($_GET['andthen'])) $prebits = ""; foreach($json_output->query->results as $event) { if ($yesh1 != "") $yesh1 = "

" . $event->name . str_replace("Worldbank Data", "Worldbank Data", $ititle) . " ... " . $date . "


"; if ($yesh1 != "" && sizeof($xrest) > 1) $yesh1 = "

Worldbank Data for " . str_replace("+", " ", str_replace("+d%27", " d", urlencode($ecountry[0]))) . " ... " . $date . "


"; if (isset($_GET['andthen'])) $yesh1 = ""; echo "\n" . $yesh1 . "
"; if (!isset($_GET['andthen'])) echo " 1) { //$bits = ""; for ($jj=0; $jj<(sizeof($xrest) - 1); $jj++) { $stuff .= "
"; $bits = ""; } } $stuff .= ""; echo $prebits . str_replace("margin-top:-90px;","align:top;",$stuff . $pstuff) . "'>"; if (!isset($_GET['andthen'])) echo "
"; } else { echo ">"; echo ""; echo ""; echo ""; } if (!isset($_GET['andthen'])) echo ""; } echo "
"; // } } ?>