Results 1 to 3 of 3
  1. #1
    mswantek is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default Listing info by date

    Hi. I am trying to loop over data from my db to produce a listing and header similar to craigslist posting.

    I need to display all items listed for date "such and such" and then go to the next previous date and do the same thing.

    Java Code:
    <sql:query var="listall" dataSource="jdbc/PPOefab" >
    SELECT *
    FROM gmlistmain
    ORDER BY  datePosted ASC
    </sql:query>
    
    <jsp:useBean id="current" class="java.util.Date"/>
    <fmt:formatDate var="dateFormatted" value="${current}" type="both"/>
    <c:out value="${dateFormatted}"/>
    <table width="88%" border="0" cellpadding="10" cellspacing="10">
      <c:forEach items="${listall.rows}" var="listallRows">
        <tr>
        <td >&nbsp;${listallRows.datePosted}</td>
            <td>&nbsp;<a href="detail.jsp?recordID=${listallRows.posting_ID}">${listallRows.postingTitle}</a>  ( ${listallRows.location} ) </td>
        <td>&nbsp;${listallRows.postingDescription} </td>
      </tr>
      </c:forEach>
    </table>
    This produces a listing but shows the date every time. How can I just show the date once (formatted as a heading) , list all the items listed on that date, and then move onto the next previous date and list all items on that day, and continue on till 30 days from today are listed. Again, a craigslist listing is similar to what I am looking for.


    I know I will need to loop over, but I am not able to figure this out. Any help would be appreciated.

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    c:set var="tmp" value="0"
    compare the date and tmp variable, if they have differences, display the date and update tmp variable to valud of date

  3. #3
    mswantek is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default

    MTYOUNG,

    Thanks for your reply. Using the distinct method in SQL, I looped through the dates and created the virtual table of distinct dates. That variable was then used to list only the items with that date under the heading of the date.

Similar Threads

  1. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 08:10 AM
  2. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 08:32 PM
  3. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 04:15 PM
  4. Listing all threads and threadgroups in the VM
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 06:36 PM
  5. Listing all available Locales
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-29-2007, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •