David Robley wrote:
Gavin Amm wrote:
That would indicate that you are actually saying:
 $monthVal = $monthName[04];

where the 04 is actually a string; you have no element '04' in your array.
Cast $monthInt to an integer before you use it as an array element.

Alternatively, if you are using MySQL, you can use DATE_FORMAT to achieve
the same result.

while ($row = mysql_fetch_array($result)){
$monthName = array ("", "Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
echo "<p><b>".$monthName[substr($row['start'], 4, 2)]."
".substr($row['start'], 6, 2)."</b><br>\n".$row['details']."\n</p>\n\n";

Yep, also - no need to redeclare $monthName each iteration. If you wanted you could also just declare it thusly:

$monthName = array ("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr", "05" => "May", "06" => "Jun", "07" => "Jul", "08" => "Aug", "09" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");

... incidentally, Oct/Nov/Dec should have worked previously afaik, PHP is fairly forgiving. You can probably also get away with just using round() to get your integers where you need them, instead of the declaration above.

- Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to