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 setup I have in a vs2008 solution: Data layer in a project
This is often situation, but here is latest example: Companies have various contact data
I'm downloaded the code from John Papa's book here: http://silverlight-data.com/ and am sucessfully running
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer
last time I asked how to populate a data structure here . Now I
ex: <a><strike>example data in here</strike></a> I want everything inside the a tag, to the
How can I represent the following in XSD. <price-update> <![CDATA[ arbitrary data goes here
Here is my Json data: [{ok : false, details : [{n : Email, v
Here is a sample code to retrieve data from a database using the yield
Here are two questions related to modifying the data source for strongly typed dataset

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.