Hi,
I'm running an sql query to print out the list of results in table format. Additional variables are determined by manipulating the data from the query result. Some of my variables are showing up properly (i.e. $ItemNum and $Descrip), but the ones dealing with $Date do not ($Day and $DayNum).
In addition to the actual $Date (yyyy-mm-dd), I need to show
The problem is that $Day and $DayNum result in the same values regardless if $Date has changed. I'm so confused how to solve this problem!
Here is the php code:
<?php
$query = "SELECT * FROM Timesheets WHERE EquipmentCode!='' ORDER BY JobCode,PhaseNum,CostCode,EquipmentCode";
$result = mysql_query($query);
while($line = mysql_fetch_array($result))
{
$Date = $line["Date"];
$EquipCode = $line["EquipmentCode"];
$Employee = $line["EmployeeName"];
// split out item num from equipment code
list($Model,$ItemNum) = split("#",$EquipCode);
// convert date to day # and day of week
$Day = date("D", $Date);
$DayNum = date("w", $line["Date"]); $DayNum = $DayNum+1;
// why is this returning the same values for date for all line items? and not the result i want!!!
$tableinfo .= "<tr bgcolor=$color>
<td nowrap class=\"small\">$EquipCode</td>
<td nowrap class=\"small\">$DayNum-$Day$Employee$ItemNum</td>
<td nowrap class=\"small\">$Date ($Day)</td>
</tr>\n";
}
?>
code continues to print results which look like
Code Description Date (Day)
H#109 4-WedA.LES109 2008-02-02 (Wed)
L#63 4-WedA.LES63 2008-01-28 (Wed)
#65 4-WedC.ROD65 2008-01-30 (Wed)
M#91 4-WedC.ROD91 2008-01-28 (Wed)
What I need is for the $Day and $DayNum values to correlate to the respective date, so that:
2008-02-02 Day = Sat; DayNum=7
2008-01-30 Day = Wed; DayNum=4
2008-01-28 Day = Sun; DayNum=1
I'm sure this is an easy fix, but everything I try produces the same (incorrect) result.
Help appreciated!