I"m writing a php/mysql blog app. I want to be able to enter multiple entries (date, title, subject, content), and then have it print the date once, title and content for each entry with that date, then go to the next date. Here is the code I am using:
function printBlog()
{
$sql = "select date_format(Date, '%m.%d.%Y') as fDate, Date, Title, Content from BlogTable where UserName = '$this->UserName' AND month(Date) = '$this->month' and year(Date) = '$this->year' order by fDate desc";
$myCont = $this->myDb->query($sql);
while ($myContent = $this->myDb->fetchObject($myCont))
{
echo "<div id=\"entry\">";
echo "<div id=\"date\">" .$myContent->fDate ."</div>";
$sql = "select BlogID, date_format(Date, '%m.%d.%Y') as fDate, Title, Content from BlogTable where UserName = '$this->UserName' and Date = '$myContent->Date' order by BlogID asc";
$myInCont = $this->myDb->query($sql);
while ($myInContent = $this->myDb->fetchObject($myInCont))
{
echo "<div id=\"title\">" .$myInContent->Title ."</div>";
echo "<div id=\"text\">" .Trim($myInContent->Content) ."</div>";
echo "<br />";
}
echo "</div>";
}
}
The first while statement works the first time. The second while statement works, but then the first while doesn't continue to loop. There are 10 different dates, and it only prints one of them. Can anybody help me out?
Thanks,
Mark Buckner