Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8353051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:08:49+00:00 2026-06-09T09:08:49+00:00

I am trying to pull messages form mysql, group them by date, and display

  • 0

I am trying to pull messages form mysql, group them by date, and display the results in listview with one header for each date.

I figured out how to group by date from mysql and order by desc timestamp.

My mind is blocked on how to display only one header for each date since is row is return using the while() function from php. Can someone shed some light?

Here’s what I have so far.

$st = $this->db->prepare("SELECT date(timestamp) as date, message, user_id, target_id, msg_id, msg_type, target_name 
FROM message  
WHERE (user_id=? OR target_id=?)  
GROUP BY date  
ORDER BY timestamp DESC");  
            $st->bindParam(1, $y['user_id'], PDO::PARAM_INT);
            $st->bindParam(2, $y['user_id'], PDO::PARAM_INT);
            $st->execute();

            echo'<ul data-role="listview" id="message_listview">';

            if($st->rowCount() < 1){
                echo'You have no messages';
                exit();
            }       

            while($row = $st->fetch(PDO::FETCH_OBJ)){
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:08:51+00:00Added an answer on June 9, 2026 at 9:08 am
    $date = ''; // initialize $date with an invalid value
    while($row = $st->fetch(PDO::FETCH_OBJ))
    {
        if($date != $row['date'])
        {
            // display date only when it changes
            $date = $r['date'];
            echo $date;
        }
        // display the other fields here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get Already up-to-date messages when trying to merge one branch, 'feature_1', into another,
I'm trying to pull the 'unread' messages from our Facebook Page (as opposed to
I'm trying to pull data from the YouTube API into a local MySQL table.
I'm trying to pull a project from git, in particular, this one: https://github.com/pocmo/Yaaic .
I'm trying to pull some data from plist file and display it in a
I'm trying to pull some binary data from a database and write them to
I'm trying to pull email addresses from a table and format them into a
I'm trying to pull a string out of my mysql DB and use a
I'm getting this strange error message when trying to clone or pull from git.
I am trying pull a field out of a string and return it. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.