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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:28:58+00:00 2026-06-15T10:28:58+00:00

I want to display MySQL results like this in a PHP/HTML table. Maybe add

  • 0

I want to display MySQL results like this in a PHP/HTML table. Maybe add mouse over info for each plant if thats easy later.

+-----------------------------------------------------------+
|category1  ¦ category2 ¦ category3 ¦ category4 ¦ category5 ¦ 
+-----------+-----------+-----------+-----------+-----------+
| plantName ¦ plantName ¦ plantName ¦ plantName ¦ plantName ¦ 
| plantName ¦ plantName ¦ plantName ¦ plantName ¦ plantName ¦ 
| plantName ¦ plantName ¦           ¦           ¦           ¦
|           ¦ plantName ¦           ¦           ¦           ¦
|           ¦ plantName ¦           ¦           ¦           ¦
+-----------+-----------+-----------+-----------+-----------+

First I select plants by elevation and rainfall values.

$sql = mysql_query("SELECT * FROM `plants_tb` 
WHERE $elevate>= elevationLOW  &&  $elevate<= elevationHI &&
$rainfall>= rainfallLOW  &&  $rainfall<= rainfallHI ORDER BY commonNames ASC");

$plant = 'commonNames';
$elevationH = 'elevationHI';
$elevationL ='elevationLOW';
$rainfallL ='rainfallLOW';
$rainfallH ='rainfallHI';
$species ='species';

echo "<table border='1'><tr><th>Name</th><th>Category</th></tr>";
while($row = mysql_fetch_array($sql)){
echo "<tr><td>" . $row[$plant] . "</td><td>" . $row['heightHI'] . "</td></tr>";
}
echo "</table>";

Now I need to display them in columns by height categories. Maybe I should make a temporary table of the selected plants, then categorize them, then display them in columns?
Here is my idea for categorizing. I know this between code is not correct but, it gets my point out.

$sql="SELECT tree_height FROM $Elevation_Rainfall_list;
WHERE tree_height
BETWEEN 1 AND 7 = $Category1
BETWEEN 7 AND 15 = $Category2
BETWEEN 15 AND 30 = $Category3
BETWEEN 30 AND 9999 = $Category4
if not = $Category5

mahalo for the support!

  • 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-15T10:28:59+00:00Added an answer on June 15, 2026 at 10:28 am

    Looks like you want to create something like a histogram.

    Instead of trying to categorize the data in the SQL query, you should do it in PHP with something like this:

    $histogram = array();
    # classify the data into histogram bins
    while($row = mysql_fetch_array($sql)) {
        $h = $row['tree_height'];
        $cat = 3;
        if ($h <= 7) {
            $cat = 0;
        } elseif ($h <= 15) {
            $cat = 1;
        } elseif ($h <= 30) {
            $cat = 2;
        }
        $histogram[$cat][] = $row['commonNames'];
    }
    
    # determine the number of rows in the table
    $rows = 0;
    foreach ($histogram as $ar) { $rows = max($rows, count($ar)); }
    
    # write a table with the data
    echo "<table border='1'>\n" .
         "  <tr>\n    <td>Category 1</td>\n    <td>Category 2</td>\n" .
         "    <td>Category 3</td>\n    <td>Category 4</td>\n</tr>\n";
    for ($i = 0; $i < $rows; ++$i) {
        echo "  <tr>\n";
        for ($cat = 0; $cat <= 3; ++$cat) {
            echo "    <td>" . $histogram[$cat][$i] . "</td>\n";
        }
        echo "  </tr>\n";
    }
    echo "</table>\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to query a table in a mysql database and display the results
I have this mysql tables I want to display with jqgrid. The problem appears
i want to retrieve image stored in mysql as path using php and display
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I'm using PHP/MySQL to make a website that displays race results. I want to
I want to display the time and date of updated row from MySQL to
I'm using MySQL to store Cyrillic and Latin strings. I want to display all
In the header of the django admin, I want display a link. This link
PHP/MySQL newbie here. I managed to develop a web page that displays info from
I'm using this calendar plugin to display my client's agenda using a mySQL db.

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.