PDA

View Full Version : Can't find mistake.


Switch17
08-13-2002, 01:33 PM
I seem to have an error someplace, but can't seem to find it. I've been developing/re-doing a fantasy football website and created some PHP files to work with a database that should update to each new week. For some reason, I can only seem to get the first weeks reports to show up, and not the week 2, 3, etc's. Its suppose to be designed to search the data base to grab the latest week so you can view that week or go back and view prior weeks by just choosing the prior week on the weeks menu, then choosing your report again. These are pieces of the PHP files if anyone can help.

This should be defining the report name for each week
$user="XXXXX";
$host="localhost";
$password="XXXX";
mysql_connect($host,$user,$password);
mysql_select_db("XXXXXX");
$query = "SELECT latest_week FROM week_index WHERE season=2001";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
if (!isset($week)) {
$week=$row[0];
$lastweek = $week;
}
else $lastweek = $row[0];
if (!isset($report)) $report=0;
$SYWC = "01";
if ($week < 10) $SYWC .= "0";
$SYWC .= $week;
$ext = ".php?week=".$week."&report=";
$FL[0] = "_standings".$ext."0";

and this should be grabbing the week from the datebase I believe
<?php
for ($i = 1; $i <= $lastweek; $i++)
{
if ($i == $week) echo("&nbsp;&nbsp;&nbsp;<span class=menuT>".$week."</span>");
else
{
echo ("&nbsp;&nbsp;&nbsp;<a href=\"");
if ($report < 5) {
echo ("01");
if ($i < 10) echo ("0");
echo ($i);
}
echo ($FL[$report]."&week=".$i."\"".$style."><span class=menu>".$i."</span></a>");
}
}
echo("<span class=menuZ>");
for ($i = $lastweek +1; $i < 18; $i++)
echo ("&nbsp;&nbsp;&nbsp;".$i);
echo("</span>");
?>

and this is my table, nice and simple here.

CREATE TABLE week_index (
ID int(11) NOT NULL auto_increment,
season year(4) NOT NULL default '0000',
latest_week int(2) NOT NULL default '0',
PRIMARY KEY (ID)
) TYPE=MyISAM;

# Dumping data for table `week_index`

INSERT INTO week_index VALUES (1,'2001',1);
INSERT INTO week_index VALUES (2,'2001',2);

Any help would be great.

Spookster
08-14-2002, 12:30 AM
If you want the most recent week then you can use sql to grab that instead of grabbing everything and then figuring out which row is the most recent:

$query = "SELECT max(latest_week) FROM week_index WHERE season=2001";