POST requests

Hi all,

With the working code below I;m trying to setup a results section that would output a soccer teams results eg.Everton have won 12, drawn 4, and lost 5 games to date.
The Position option works fine but I;m not sure how to integrate the additional function within the code?
[php]

.red {color: red} Table <?php if ($_SERVER["REQUEST_METHOD"] == "POST" ){ $tablesPage = "http://www.bbc.com/sport/football/tables"; $resultsPage = "http://www.bbc.com/sport/football/results"; // I need this to output results data as in the tables option if(!empty($_POST["team"])){ $teamData= getTeamData($_POST["team"] , $tablesPage); if(!empty($_POST["data"]) && $_POST["data"] == "position"){ echo getPosition($teamData); } } } function getPosition($teamData){ return "Team ". $teamData["team"] ." are currently number " . $teamData["position"] . " in the league "; } function getTeamData($team, $tablesPage){ $html = new DOMDocument(); @$html->loadHtmlFile($tablesPage); @$xpath = new DOMXPath($html); / $items = $xpath->query('//td/a[text()="' . $team . '"]/../..'); $values[] = array(); foreach($items as $node){ foreach($node->childNodes as $child) { if($child->nodeType == 1) array_push($values, $child->nodeValue); } } $values[2] = substr($values[2], -1); $values = array_slice( $values, 2, count($values)-4); $keys = array("position", "team", "played", "won", "drew", "lost", "for", "against", "difference", "points"); return array_combine($keys, $values); } ?>
Select a team and a data item about that team Everton Chelsea Southampton Liverpool Arsenal position results [/php]

so…what happens when you try this code? what error?

Sponsor our Newsletter | Privacy Policy | Terms of Service