You had help me with this code below looking for either todays date or it shows all dates. Then it grabs and post that data.. If I wanted the date range to be about a week or lets say 5 days, then how do I accomplish this? Thank you. Johnny
<?php
require("MagicParser.php");
print "<table border='1' width=\"550\" align='center' cellspacing=\"0\" cellpadding=\"1\">";
print "<tr>";
print "<th>Date &<BR>Time</th>";
print "<th>Teams</th>";
print "<th>#</th>";
print "<th><a href=\"http://www.newbodog.com/servlets/Welcome?ID=1350\"><img src=\"images/bodog2.gif\" border=\"0\"></a></th>";
print "<th><a href=\"http://www.vip.com/?skin=sports&CampaignID=36559\"><img src=\"images/VIPsports.jpg\" border=\"0\"></a></th>";
print "<th><a href=\"http://www.beted.com/B95CEF3D-774A\"><img src=\"images/beted2_rollover.gif\" border=\"0\"></a></th>";
print "<th><a href=\"http://affiliates.commissionaccount.com/processing/clickthrgh.asp?btag=a_4774b_282\"><img src=\"images/sportsbook_com.jpg\" border=\"0\"></a></th>";
print "<th><a href=\"http://www.commissionking.com/_9c78e40c1398cd6661c7310afe29d228/1/\"><img src=\"images/canbet_rollover.gif\" border=\"0\"></a></th>";
print "</tr>";
function myRecordHandler($record)
{
global $counter;
//Convert the time
$time = $record["GAME-DATE"]." ".$record["GAME-TIME"];
$time = strtotime($time);
$time = date("g:i A",$time);
//Convert the Date
$date = $record["GAME-DATE"]." ".$record["GAME-TIME"];
$date = strtotime($date);
$date = date("d-M",$date);
//Get today's date
$today = date("d-M");
//Exit if not today
//if ($date <> $today) return;
//Display the game
if ($counter++ % 2)
{
print "<tr>";
}
else
{
print "<tr bgcolor='#fefee6'>";
}
// first display the game information columns
print "<td valign='top'>".$time."<br />".$date."</td>";
print "<td valign='top'>".$record["GAME-HOMESHORT"]."<br />".$record["GAME-AWAYSHORT"]."</td>";
print "<td valign='top'>".$record["GAME-HOMEROT"]."<br />".$record["GAME-AWAYROT"]."</td>";
// now load all books into an array indexed by book name so we can display the ones we want
$books = array();
$i = 0;
while(1) {
if ($i) $postfix = "@".$i;
$bookName = $record["BOOK".$postfix."-NAME"];
if (!$bookName) break;
$books[$bookName]["AWAYML"] = $record["BOOK".$postfix."-AWAYML"];
$books[$bookName]["HOMEML"] = $record["BOOK".$postfix."-HOMEML"];
$books[$bookName]["AWAYSPREAD"] = $record["BOOK".$postfix."-AWAYSPREAD"];
$books[$bookName]["AWAYLINE"] = $record["BOOK".$postfix."-AWAYLINE"];
$books[$bookName]["HOMESPREAD"] = $record["BOOK".$postfix."-HOMESPREAD"];
$books[$bookName]["HOMELINE"] = $record["BOOK".$postfix."-HOMELINE"];
$books[$bookName]["TOTAL"] = $record["BOOK".$postfix."-TOTAL"];
$books[$bookName]["OVERLINE"] = $record["BOOK".$postfix."-OVERLINE"];
$books[$bookName]["UNDERLINE"] = $record["BOOK".$postfix."-UNDERLINE"];
$i++;
}
// create an array of the books we want, matching the title row
$useBooks = array("bodog2","vipsports2","beted2","sportsbook","canbet");
// now display each book in $useBooks array
foreach($useBooks as $bookName)
// Return of Empty fields as N/A - NOT WORKING
if ($books[$bookName]["HOMESPREAD"])
{
print "<td>";
print $books[$bookName]["HOMESPREAD"].$books[$bookName]["HOMELINE"];
print "<br />";
print $books[$bookName]["AWAYSPREAD"].$books[$bookName]["AWAYLINE"];
print "<br />";
print $books[$bookName]["TOTAL"]." ov".$books[$bookName]["OVERLINE"];
print "</td>";
}
else
{
print "<td>N/A</td>";
}
//End of Return field with N/A
}
MagicParser_parse("http://www.pointspread.com/liveodds/xml/xml_general_nfl.xml","myRecordHandler","xml|ODDS/GAME/");
print "</table>";
?>
Hi,
To do that, replace the following line:
// if ($date <> $today) return;
(although it is commented out in the code you posted above)
...with something like this:
$test = $record["GAME-DATE"]." ".$record["GAME-TIME"];
$test = strtotime($test);
// now set the $from and $to for the period you want, so if you want the next 5 days:
$from = strtotime("now");
$to = strtotime("+5 days");
// now exit if $test is not between $from and $to, so we only display the dates we want:
if (!(($from < $test) && ($test < $to))) return;
For more information on the formats you can use in the strtotime() function, see:
http://uk.php.net/strtotime
Hope this helps!
Cheers,
David.