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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:50:50+00:00 2026-06-12T20:50:50+00:00

Let’s say I have this loop in my header.php: <div id=top-20> <h2 class=top-20-title>TOP 20

  • 0

Let’s say I have this loop in my header.php:

<div id="top-20">
    <h2 class="top-20-title">TOP 20 TEAMS</h2>

    <div class="top-20-content">

        <?php
            $params = array(
               'limit'   => -1 // get everything
            );

            $matches = pods( 'matches', $params );

            if ( 0 < $matches->total() ) {
                while ( $matches->fetch() ) {
            ?>

                 <?php echo $matches->field( 'winner_team' ); ?>
                 <br>

            <?php
                    } // end of while loop
                } // end of if any exists
            ?>

    </div><!-- /top-20-content -->  
</div><!-- /top-20 -->  

And this is what my simplified table looks like:

id | team_1 | team_2 | winner_team
--------------------------------
1  | 3      | 15     | 3
--------------------------------
2  | 20     | 8      | 8
--------------------------------
3  | 18     | 11     | 18
--------------------------------
4  | 8      | 7      | 8
--------------------------------
...

But I want instead of echoing inside while loop like

<?php echo $matches->field( 'winner_team' ); ?>

create a new array i.e. $matches_array which will contain 2 columns like id_new and winner_team_new and save the value of winner_team in winner_team_new instead of echoing it directly inside while loop.

Then I would like to loop this new created array $matches_array inside another while loop after groupby occurrences of winner_team_new and orderby them DESC.

So, I will get something like this:

8
3
18

instead of what I am currently getting when using echo in while loop:

3
8
18
8

Why I can not just do it inside sql? I need to be done using another array not using conditions in $params or sql array due to this bug: https://github.com/pods-framework/pods/issues/595 and the fact that pods framework is too complicated for my to make my own code adjustements into core so I would like to bypass this by working with an array that will be created from while loop.

So, what I need is to create an array and rearange the results based on occurrences of winner_team from the most to the less.

I have tried using

$matches_array = array_count_values(array_map($matches,array_keys($new_row)));

And then loop it in while loop but it is not working at all.

I need help with the count array/group by part.

I don’t know practically anything about it.

I just guess that I need after grouping based on the same winner_team field create a new field e.g. wins where the number of occurrences for every team(based on winner_team) value will be stored. And then order that new array DESC.

Btw. all columns in the table are INTEGERS

EDIT 2:
I have figured out how to store values from the while loop inside a new array called $matches_array and the code looks like this:

<div id="top-20">
    <h2 class="top-20-title">TOP 20 TEAMS</h2>

    <div class="top-20-content">

        <?php
            $params = array(
               'limit'   => -1 // get everything
            );

            $matches = pods( 'matches', $params );

            if ( 0 < $matches->total() ) {
                while ( $matches->fetch() ) {
            ?>

                 <?php // echo $matches->field( 'winner_team' ); ?>
                      <?php $row_array = $matches->field( 'winner_team' ); ?>
                      <?php $matches_array[]; ?>

                 <br>

            <?php
                    } // end of while loop
                } // end of if any exists
            ?>

    </div><!-- /top-20-content -->  
</div><!-- /top-20 -->

Now, I need probably do a foreach loop after a groupby(based on occureces of the numbers in winner_team field) and order the result before the output DESC.

Any advice how to do that?

  • 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-12T20:50:51+00:00Added an answer on June 12, 2026 at 8:50 pm

    The issue that initially kept you from sorting by an aliased column should be resolved. I’ve tested it with the initial scenario and it’s doing exactly what it should. I think you can happily discard this attempted work-around.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let me explain best with an example. Say you have node class that can
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say I have the following classes : public class MyProductCode { private String
Let say I've this URL: http://example.com/image-title/987654/ I want to insert download to the part
Let's say you have an array like this: array ( ['one'] => array (

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.