Monks, I'm a little stumped here. I am printing out a sort of list view of a calendar. I'm trying to only print the date heading once if there is more than ne reservation on that date. It would look something like this:
2020-03-21 | 2:00 pm | 3:00 pm 2020-03-22 | 2:00:pm
I am looping through, but I can't figure out how to NOT print the date again if it has already been printed. I have something like the following (this is not the actual code):

$SQL = "SELECT * from $reservations_table where approved!='declined' a +nd date > '$dateadded2' OR (date = '$dateadded2' and militaryendtime +> '$hourmin' and approved!='declined' and approved!='cancelled') orde +r by date asc, militarytime asc"; &Do_SQL; $startcount = ($currentpage - 1) * $titlesperpage + 1; $stopcount = $currentpage * $titlesperpage; $current_count = 0; while (($pointer = $sth->fetchrow_hashref) && ($current_count +<= $stopcount)){ $current_count++; if ($current_count >= $startcount && $current_count <= $st +opcount) { print <<HTML; <table border=0 cellpadding=5 cellspacing=5> <tr> <td width=100 align=center><b>$date</b></td> <td width=100 align=center>$time_lc</td> <td>-</td> <td width=100 align=center>$endtime_lc</td> <td width=100 align=center>$area</td> <td width=100 align=center>$unit</td> </tr> </table> } }

I tried to set a $lastdate = $date after the loop, then compare it on the next loop but I'm doing something wrong. Any ideas? Thanks!


In reply to Matching Dates by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.