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

  • Home
  • SEARCH
  • 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 6231067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:52:00+00:00 2026-05-24T09:52:00+00:00

I have the following code: //set $message and run database query $message .= ‘<body

  • 0

I have the following code:

//set $message and run database query
$message .= '<body style="margin: 0;">';
$message .= '<div style="padding: 0 20px;">';
$message .= '<span style="display: block; font-size: 22px; font-weight: bold; margin: 25px 0 -15px 0;"> User Activity on ' . $website . ' for ' . $yesterday . '</span>';


//query the database for today's history
$result = mysql_query("SELECT * FROM user_history WHERE date = '$yesterday' ORDER by name, time, title") 
or die(mysql_error());
$old_user = '';   

    while($row = mysql_fetch_array( $result )) {
        $new_user = $row['uid'];
        if ($new_user != $old_user) {
            $message .= '<br /><br /><hr />' . '<span style="font-size: 18px; font-weight: bold;">' . $row['name'] . '</span>' . '<br />' . $row['company'] . '<br />' . $row['email'] . '<br />' . $row['phone'] . '<br /><br />';
            $old_user = $new_user;
        }
        $message .= '<ul><li>' . $row['time'] .
    '<ul><li>' . $row['title'] . ' (<a href="' . $row['url'] . '">' . $row['url'].     '</a> )' . '</li></ul>' . '<br /><br />' .
    '</li></ul>';
    }  


//if no user activity, simply say so
if($new_user == "") {
    $message .= '<br /><br /><hr /><span style="font-size: 18px; font-weight: bold;">No user activity to report</span>';
}

$message .= '</div>';


$message .= '<div style="position: fixed; bottom: 0; height: 40px; width: 100%; margin: 20px 0 0 0; background: #000; color: #FFF; line-height: 40px; padding: 0 20px;">' .
'Report generated ' . $date . ' ' . $time .
'</div>';

$message .= '</body>';

It works beautifully in the mail function. The output email groups like this…

John Doe
John Doe’s Company
johndoe@johndoeco.com
800-555-0000

*1:30pm
*Video 1

*1:47pm
*Video 2

*1:47pm
*Video 3

==============================

Instead, I’d like to output like this:

John Doe
John Doe’s Company
johndoe@johndoeco.com
800-555-0000

*1:30pm
*Video 1

*1:47pm
*Video 2
*Video 3

=============================

Can someone please tell me how to make this happen? Thanks!

  • 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-05-24T09:52:00+00:00Added an answer on May 24, 2026 at 9:52 am

    Just keep track of the current time value using the same technique that you are doing for distinct users (if ($new_user != $old_user) {) but for the time value.

    Something like

    if ($new_user != $old_user) {
         //your existing code
         $old_time = null;
         $end_tag = false;
    }
    
    if ($old_time == null || $row['time'] != $old_time) {
        $old_time = $row['time'];
        $message .= '<ul><li>' . $row['time'];
        $end_tag = true;
    }
    
    $message .= '<ul><li>' . 
                 $row['title'] . ' (<a href="' .
                 $row['url'] . '">' . $row['url'].     '</a> )' .
                '</li></ul>';
    
    if ($end_tag) {
        $message .= "</li></ul>";
        $end_tag = false;
    }
    

    Though coding this way starts to get ugly fast and should be split up into functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code set up in my Startup IDictionary<string, string> properties =
I have the following code to set a userId variable: (userId set in prior
I have following code in my application: // to set tip - photo in
I have the following code: UPDATE myTable SET Col1 = @Value However, I have
I have the following code: private static final Set<String> allowedParameters; static { Set<String> tmpSet
I have the following code that seems like it should set my insertParameter but
I have to following code fragment, and no matter what I set the font-size
I have using following code to set a thread on button action. public void
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section

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.