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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:59:25+00:00 2026-05-26T16:59:25+00:00

I have an indefinite amount of items in an array: $query = mysql_query(SELECT *

  • 0

I have an indefinite amount of items in an array:

$query = mysql_query("SELECT * FROM orders WHERE orderID = '$orderID'");        

while($row = mysql_fetch_array($query)){
   $items[] = $row[itemnumber];
   $quantity[] = $row[quantity];
   $vendoremail[] = $row[vendoremail];
} 

The values in the arrays could be something like this:

 $items = ("A","B", "C");
    $quantity = ("2", "1", "3");
    $vendoremail = ("name1@email.com", "name2@email.com", "name1@email.com");

I want to group the data from the same email addresses and send a single email to each address.

So one email gets sent to name1@email.com with the items “A” and “C” and quantity “2” and “3” in the body of the email.

And another email gets sent to name2@email.com with the items “B” and quantity “1” in the body of the email.

Anybody know the best way to accomplish this?

  • 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-26T16:59:25+00:00Added an answer on May 26, 2026 at 4:59 pm

    You can group the values into comma-separated strings via GROUP_CONCAT() and optionally split them back up in PHP:

    SELECT 
      GROUP_CONCAT(itemnumber) AS items,
      GROUP_CONCAT(quantity) AS quantities,
      vendoremail
    FROM orders
    WHERE orderid = '$orderID'
    GROUP BY vendoremail
    

    This will produce results like:

    name1@email.com    A,C    2,3
    name2@email.com    B      1
    

    In PHP, if you need to you can explode() the lists back out into arrays to display in the email body.

    $results = array();
    while($row = mysql_fetch_array($query)){
       $results[] = $row; 
    }
    foreach ($results as $result) {
      $email = $result['vendoremail'];
      $items = explode(",", $result['items']); // now it's an array...
      $quantities = explode(",", $result['quantities']);  // now it's an array...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a indefinite amount of in-line elements being output. Now, depending on browser
I am running this query, $this->db->select('news.news_id, news.title, news.article, news.date_posted, news_assets.news_assets_id, news_assets.url') ->from('news_assets') ->join('news', 'news_assets.news_news_id
Do you have any idea how to implement an indefinite scroll widget like google
I have seen a few variants of this nested UL array question on stackoverflow,
I have a string command I'd like to execute asynchronously while writing to its
I have a PHP script with infinite loop. I need this script running forever.
Suppose we have an iterator (an infinite one) that returns lists (or finite iterators),
I really want to have a column of inifinite length for one of the
If I have a thread in an infinite loop, is there a way to
I have a very simple TCP server written in C. It runs indefinitely, waiting

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.