Login   Register  
PHP Classes

File: test_score.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jojo Evangelista  >  Score Scraper  >  test_score.php  >  Download  
File: test_score.php
Role: Example script
Content type: text/plain
Description: sample php usage
Class: Score Scraper
Retrieve scores of Major US Sports Leagues
Author: By
Last change:
Date: 8 years ago
Size: 1,650 bytes


Class file image Download
<Title>Test for Score Scraper Class by Dyodyo</Title>

        <form method="POST" action="test_score.php">
            Get Scores For:
            <select name='league'>
                <option value='nba'>NBA</option>
                <option value='nfl'>NFL</option>
                <option value='nhl'>NHL</option>
                <option value='mlb'>MLB</option>
                <option value='ncf'>NCAA Football</option>
                <option value='ncb'>NCAA Basketball</option>
            <input type="submit" value="submit">
require_once ("class_ScoreScraper.php");
// $_POST['league'] = 'nhl';
if ( (isset($_POST['league']))){
$ss = new ScoreScraper();
$league $_POST['league'];
     if (!
$ss->fetchScore($league)) {
"Fetching Scores for <b>".strtoupper($league)."</b><br><br>";
//write the scores to the screen
if ((is_array($ss->scores)) && (count($ss->scores)>0)) {
         foreach (
$ss->scores as $score){
"Game date: ".date("m-d-y"$score['gameDate'])."<br>";
"Game started? ".($score['isStarted']?"Yes":"No")."<br>";
             if (
$score['isStarted']) {
"Period: ".$score['periodRemain'].' - '.$score['period']."<br>";
"Home: ".$score['homeTeam']." - ".$score['homeTeamScore']."<br>";
"Visitor: ".$score['awayTeam']." - ".$score['awayTeamScore']."<br>";
             } else {
"Game Time: ".$score['gameTime']."<br>";
$score['awayTeam']." at ".$score['homeTeam']."<br>";
     } else {
// scores variable is invalid, it would mean that there are no games today...
echo $ss->error."<br>";