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 6031729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:13:41+00:00 2026-05-23T05:13:41+00:00

I am pretty lost here. I need to know if there is a way

  • 0

I am pretty lost here.

I need to know if there is a way to send a PHP email with HTML contents generated by a loop (mySQL loop I think)

I do not have any code right now because I am still looking for a way to achieve this.

In few words I need to send an HTML email by a PHP code.

This HTML mail will contain some static contents.

Some other contents will be instead taken from mySQL.

The problem is that I have some tables that could need to be duplicated for each content I have to send.

I will explain.

My users can submit a form.

This form is to provide the details of 1 or MORE authors.

When they submit the form all the details go to the Database.

If they enter the details for more authors, each author will have its own database table.

Now when there are more authors an HTML email should be sent including all the info for EACH author they have entered the info for.

Since the HTML mail has been made by simple HTML tables, this is the structure that the HTML mail will have to assume.

1° Table for 1° Author

2° Table for 2° Author

3° Table for 3° Author

etc..

Now my question is simple. Is this possible by simply using a mySQL loop?

If yes how?

Could you provide a very basic sample to let me understand?

Or should I use something else?

Thank you

  • 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-23T05:13:42+00:00Added an answer on May 23, 2026 at 5:13 am

    I think you should consider a different DB layout, which also would kinda solve that problem:
    Instead of one table per author (which you should never do) create on table with all the authors and one “content-table” which stores basicaly the same information as your current “auther-tables”, but each row is linked with a foreign key to an author in the authors-table. Then you can SELECT, ORDER and GROUP BY authors with a simple join and easily get all data with one query.
    With the result of that query you can then easily create your HTML-Tables in PHP:

    If you execute the following query

    SELECT a.author_name AS name, c.content_title AS title
        FROM content c JOIN author a ON a.author_id=c.author_id
        ORDER BY a.author_name
    

    you can do something like that in PHP:

    if(count($result) > 0)
    {
        $currentName = $result[0]['name'];
        $tables = "<table><tr><th>" . $currentName . "</th></tr>";
        foreach($result as $row)
        {
            if($currentName != $row['name'])
            {
                $currentName = $row['name'];
                $table .= "</table><table><tr><th>" . $currentName . "</th></tr>";
            }
            $table .= "<tr><td>" . $row['title'] . "</td></tr>";
        }
        $table .= "</table>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not an ASP developer so pretty lost here. Need to set up
Pretty simple question. I've got some Polygons and GroundOverlays defined in KML. Is there
Pretty sure there is an easy answer to this, but just can't find the
Pretty basic question, I know... I just don't know how it's done. I want
Is there a simple way to change the text color of a WPF Toolkit
I really have little idea how ACL do work. I know it's pretty cool
This is my first dive into MSBuild so I'm feeling pretty lost. The end
I'm pretty much stuck here. I'm looking at this module and i'm looking at
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
Pretty much the opposite of server-side push, also known as Comet . I'm wondering

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.