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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:17:50+00:00 2026-05-25T10:17:50+00:00

I got a code which generate a table like this and the code is

  • 0

I got a code which generate a table like this

table

and the code is here

$num1 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic1' && Indicator='$ind1' && IndicatorSubGroup='$subindg1' && (Country IN ('$sql_cntys') OR  WHORegionAC IN ('$sql_cntys')) ");
$num2 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic2' && Indicator='$ind2' && IndicatorSubGroup='$subindg2' && (Country IN ('$sql_cntys') OR  WHORegionAC IN ('$sql_cntys')) ");
$num3 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic3' && Indicator='$ind3' && IndicatorSubGroup='$subindg3' && (Country IN ('$sql_cntys') OR  WHORegionAC IN ('$sql_cntys')) ");
$num4 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic4' && Indicator='$ind4' && IndicatorSubGroup='$subindg4' && (Country IN ('$sql_cntys') OR  WHORegionAC IN ('$sql_cntys')) ");
$num5 = mysql_query("SELECT * FROM mtable WHERE DataVersionDate='$datav' && Pathogen='$pathogen' && Topic='$topic5' && Indicator='$ind5' && IndicatorSubGroup='$subindg5' && (Country IN ('$sql_cntys') OR  WHORegionAC IN ('$sql_cntys')) ");

$data = array();

while($row = mysql_fetch_assoc($num1))
{
    $c = $row['Country'];
    if (!isset($data[$c]))
    {
        $data[$c] = array('Country' => $c);
    }
    $data[$c]['MidEstimate1'] = $row['MidEstimate'];
}
while($row = mysql_fetch_assoc($num2))
{
    $c = $row['Country'];
    if (!isset($data[$c]))
    {
        $data[$c] = array('Country' => $c);
    }
    $data[$c]['MidEstimate2'] = $row['MidEstimate'];
}

while($row = mysql_fetch_assoc($num3))
{
    $c = $row['Country'];
    if (!isset($data[$c]))
    {
        $data[$c] = array('Country' => $c);
    }
    $data[$c]['MidEstimate3'] = $row['MidEstimate'];
}

while($row = mysql_fetch_assoc($num4))
{
    $c = $row['Country'];
    if (!isset($data[$c]))
    {
        $data[$c] = array('Country' => $c);
    }
    $data[$c]['MidEstimate4'] = $row['MidEstimate'];
}

while($row = mysql_fetch_assoc($num5))
{
    $c = $row['Country'];
    if (!isset($data[$c]))
    {
        $data[$c] = array('Country' => $c);
    }
    $data[$c]['MidEstimate5'] = $row['MidEstimate'];
}
$i = 0;
echo "<table width='880' align='center'>";
foreach ($data as $row)
{
    echo ($i % 5) ? "<tr>" : "<tr>" ;
    echo "<td style='padding-left:10px' width='280'>" . $row['Country']."</td>";
    echo "<td align='center' width='120'>" . $row['MidEstimate1']."</td>";
    echo "<td align='center' width='120'>" . $row['MidEstimate2']."</td>";
    echo "<td align='center' width='120'>" . $row['MidEstimate3']."</td>";
    echo "<td align='center' width='120'>" . $row['MidEstimate4']."</td>";
    echo "<td align='center' width='120'>" . $row['MidEstimate5']."</td>";
    echo "</tr>" ;
}

echo "</table>" ;

How can I sort this table column wise ? that is using a drop down list with values “Country”, “Indicator 1”, “Indicator 2”, “Indicator 3”, “Indicator 4”, “Indicator 5”. when a user select values table must list values with respective sorted column. Please help.

I got the answer from here Sort Multi Array

  • 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-25T10:17:51+00:00Added an answer on May 25, 2026 at 10:17 am
        <?PHP 
    function orderBy($data, $field) { 
    $code = "return strnatcmp(\$a['$field'], \$b['$field']);"; 
    usort($data, create_function('$a,$b', $code)); 
    return $data; } 
    
    $data = orderBy($data, 'age'); 
    ?>
    

    The complete reference of the code is available from here

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

Sidebar

Related Questions

I've got some code which draws data from an xml file but it seems
I've got some code which I would like to translate into Opengl ES. I'm
Ive got the following code which I hacked together from website examples. It works
So I've got this ginormous humungous class, of which the only relevant code is:
I've got some code which accepts a DataTable as a parameter and calculates the
I've got some code which I use to loop through the properties of certain
Basically I've got a code which should load a lot of images so I
I've got some code which sets up a datacontext. Often enough, the datacontext should
I've got a code (which works fine) for piloting word with C++ Builder. It's
I've got some code which works fine in IE but unfortunately not in Google

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.