Hello fellow daniwebians, I seem to have run into a problem echoing MySQL/HTML and am hoping one of you may be able to point me in the right direction.
I'm trying to echo portions of HTML(if there is an event for that date) inside HTML that's not echoed, so it should always show up.
I am writing a while loop on either side of the HTML in case there is more than one event on that date. The problem is, it won't display the HTML that's not echoed whenever I use the loop. If I remove the loop, it works fine.
I've used this technique on other sites with no problems in the past... hope I'm just missing something simple... I have to fix it 364 more times :)
<? $result = mysql_query("SELECT * FROM cal WHERE date='(2012-01-01)' "); ?>
<?
$num_rows = mysql_num_rows($result);
$i = 0;
while($i < $num_rows)
{
$row = mysql_fetch_array($result);
?>
<td <? if (!empty($row['event'])){echo "class=\"date_has_event\"";} ?>> 1
<? if (!empty($row['event'])){
echo "<div class=\"events\">
<ul>
<li>
<span class=\"title\">".$row['title']."</span>
<span class=\"desc\">".$row['event']."</span>
</li>
</ul>
</div>";}
?>
<?$i++; }?>
</td>
as you can see, the ultimate goal, if there is not an event...
<td>/*number*/</td>
and if there is one or more...
<td class="date_has_event">/*number*/
<div class="events">
<ul>
<li>
<span class="title"><?$row['title']?></span>
<span class="desc"><?$row['event']?></span>
</li>
...
</ul>
</div>
</td>
I've tried to put everything in an echo (both the stuff that should always be there and the conditional stuff) with the same result (no HTML at all)... Please, let me know if you have any ideas.