breaking up records.
| From: | Bruce Levick | Date: | Thu, 10 Apr 2003 13:31:58 +0000 |
| Subject: | breaking up records. | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26988@lists.php.net to get a copy of this message | ||
Hi Phper's
I am returning some dates from a rescordset. At Present it displays
something like this.
10May
09Apr
09Apr
08Apr
08Apr
08Apr
08Apr
I have broken up the string so I can display the Motnth (May) and the Day
(10) as I please. I am hoping to be able to display the records like this
below.
But am having trouble achieving a while or a do while.
May
10
Apr
09, 08, 08, 08, 08
I have something like this and of course it is wrong...;0)
// code for displaying the month and the days in that month horizontally
across
while ($slctArchiverow = mysql_fetch_array... //fetching the array
// obtaining the month and day from the string
$getMonth = substr($slctArchiverow[diaryMonth],3); //month
$getDay = substr($slctArchiverow[diaryMonth],0,2); //day
echo $getMonth; //displays the month (May)
do //display the days that are within May
{
echo $getDay; //display the string which is the day of the month
echo ", ";
} while ($getMonth == $getMonth); //while the month is equal to May
echo "<br>";
}
}
Is it possible to do it in this way or do I need to use if statements for
each month of the year??
eg.
if ($getMonth = May) // and so on for all 12 months.
What are your thoughts??