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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:34:22+00:00 2026-05-20T05:34:22+00:00

Here is the data I have: ID | Name | Family 1 | John

  • 0

Here is the data I have:

ID | Name | Family
 1 | John | Doe
 2 | Jane | Doe
 3 | John | Man
 4 | Jane | Blah

Basically what I am trying to do is group them by Family. I am getting the data inside a while statement and I just tried using array and array_push but that doesn’t work at all.

Any ideas or suggestions on how to do this?

I am going to ouput this data for jquery for creating optgroups which would be grouped by Family. Currently here is what is happening:

while ($orders_status = tep_db_fetch_array($orders_status_query)) {
    $status_id = $orders_status['orders_status_id'];
    $status_name = $orders_status['orders_status_name'];
    $status_group = $orders_status['orders_status_group'];
}

That’s the basic code. I tried doing this to the above mentioned code:

while ($orders_status = tep_db_fetch_array($orders_status_query)) {
    $status_id = $orders_status['orders_status_id'];
    $status_name = $orders_status['orders_status_name'];
    $status_group = $orders_status['orders_status_group'];

    echo 'if (currentOption.val() == "' . $status_id . '") {
              var optgroup = $("<optgroup/>");
              optgroup.attr("label", "' . $status_group . '");
              currentOption.wrapAll(optgroup);
          }
    ';
 }

What that did is basically created multiple Family of Doe. Instead I would like to somehow create only one Family of Doe and push Name and ID into it

  • 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-20T05:34:23+00:00Added an answer on May 20, 2026 at 5:34 am
    $groups = array();
    foreach ($rows as $row) {
      $family = $row["family"];
      if (empty($groups[$family])) $groups[$family] = array();
      $groups[$family] []= $row;
    }
    
    // $groups["Doe"] will have the two relevant rows...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the problem: I have a data-bound list of items, basically a way for
So here's the problem. I have data in a MySQL DB as text. The
I'm learning assembly and I have a very basic loop here segment .data msg:
Here's the issue: I have 2 data contexts that I would like to do
Here's a simplified version of the 3 data sets I have: Set A =
Here I have to send and receive dynamic data using a SysV message queue.
Here is the sample data for test table I have [childId] [parentId] [present] 1
Here is the scenario: I have a visual that displays some data The data
Here's the scenario: I have 2 tables with data, one is the 2009 version
I have this link created in PHP: echo '<p style=font-family: arial;>Solution name: <a class=expand_suggested_solution

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.