view_all_forecasts($start,$display); //if empty response print service unavailable message if(empty($xml)){ $htm = ""; return $htm; } //check that $xml response is returned from api if(!empty($xml)){ if ($xml->status['code']=='400'){ $error_message=$xml->status->messages->message; return "

$error_message

Please check your admin setting

"; } //parse total number of records from response $num_records = $xml->forecasts['total_results']; // Determine how many pages there are. if (isset($_GET['np'])) { // Already been determined. $num_pages = $_GET['np']; } else { // Need to determine. // Calculate the number of pages. if ($num_records > $display) {// More than 1 page. $num_pages = ceil ($num_records/$display);// use ceil to round up to nearest number. } else { $num_pages = 1; } } // End of np IF. $htm = "
"; $htm .= "

View All Market Forecasts

"; if($status_code = "200"){ foreach($xml->charts->image as $image){ $image_title = $image['alt']; $image_url = $image['url']; $image_height = $image['height']; $image_width = $image['width']; $htm .= "

$image_title

"; } $htm .= ""; }//end if($status_code = "200") $q_url_structure = get_bloginfo('url')."/agentrank/forecasts"; // Make the links to other pages, if necessary. if ($num_pages > 1) { // Determine what page the script is on. $current_page = $start; // If it's not the first page, make a Previous button. if ($current_page != 0) { $htm .= "Previous "; } // Make all the numbered pages. for ($i = 0; $i < $num_pages; $i++) { if ($i != $current_page) { $htm .= "" . ($i+1) . " "; } else { $htm .= ''; $htm .= ($i+1); $htm .= ''; $htm .= ' '; } } // If it's not the last page, make a Next button. if (($current_page+1) != $num_pages) { $htm .= "Next"; } } // End of links section. $htm .= "
"; }//end of if(!empty($xml)) return $htm; ?>