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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:30:14+00:00 2026-06-13T10:30:14+00:00

I have the following PHP code which runs a MySQL query and returns the

  • 0

I have the following PHP code which runs a MySQL query and returns the results as an array:

function mysql_resultTo2DAssocArray ( $result) {
    $i=0;
    $ret = array();
    while ($row = mysql_fetch_assoc($result)) {
        foreach ($row as $key => $value) {
            $ret[$i][$key] = $value;
            }
        $i++;
        }
    return ($ret);
    }
$compare = mysql_resultTo2DAssocArray(mysql_query("SELECT Temp.School, Temp.Status, Snow.Token FROM Temp
 JOIN Snow ON Temp.School = Snow.School"));

The results of this look like:

Array
(
    [0] => Array
        (
            [School] => School Name 1
            [Status] => Delayed Two Hours
            [Token] => Token1
        )

    [1] => Array
        (
            [School] => School Name 1
            [Status] => Delayed Two Hours
            [Token] => Token2
        )

)

Is it possible to combine the Token items by a comma within those arrays if the School item is the same for each?

One thing is that it’s possible for there to be more arrays within the global array, with different School names, that shouldn’t be grouped but left alone. Basically, is it possible to ONLY group when School is the same. It’s also possible for there to be more than two tokens.

  • 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-06-13T10:30:16+00:00Added an answer on June 13, 2026 at 10:30 am
    SELECT Temp.School, Temp.Status, GROUP_CONCAT(Snow.Token) Tokens
    FROM Temp JOIN Snow USING (School)
    GROUP BY Temp.School
    

    This isn’t completely valid, because the Status column is not aggregated or part of the GROUP BY; however MySQL normally allows it (there’s an option to disallow it, I don’t remember the name offhand). If there are rows with different Status values, it will pick one of them arbitrarily; you didn’t say what should happen with different Statuses.

    • 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 which encodes json in php $arr = array('htmlOutput' =>
I have the following code which uses an array to write the result to
I have the following php code which I found here : function download_xml() {
I have the following php code (getRout.php).. which response results in xml formats ...
I have a PHP script which runs a MySQL query. $query = INSERT INTO
I have the following php code which I want to add a delay too:
I have the following PHP code which works out the possible combinations from a
I have the following lines of php code which should rename a file which
I have the following piece of code which outputs a long article: <?php the_content();
I have the following code: <div><strong>Name: </strong><?php echo anchor('http://'.$link, $row->Name); ?></div> Which takes a

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.