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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:00:29+00:00 2026-05-14T15:00:29+00:00

I need to retrieve data (vehicle details, in this case) from a MySQL table

  • 0

I need to retrieve data (vehicle details, in this case) from a MySQL table tabled and then loop through the results to generate separate lists for each category of vehicle. Is there a simple way to do this without having to have a SELECT statement for each type of vehicle?

If I were just doing this for one category, I would use the following:

<?php
$sql = "SELECT * FROM apparatus WHERE vehicleType = 'Support';
$getSQL = mysql_query($sql);
?>

<ul>
<?php while ($vehicleData = mysql_fetch_assoc($getSQL)) {?>
<li><?php echo $vehicleData['name'];?></li>
<?php } ?>
</ul>

..etc. Need to do this for four different types of vehicles.

Thanks!

  • 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-14T15:00:29+00:00Added an answer on May 14, 2026 at 3:00 pm

    Building on Mark’s Answer, you can select all the vehicles, and rearrange your result set in php:

    <?php
      $sql = "SELECT * FROM apparatus ORDER BY vehicleType";
      $getSQL = mysql_query($sql);
      // transform the result set:
      $data = array();
      while ($row = mysql_fetch_assoc($getSQL)) {
        $data[$row['vehicleType']][] = $row;    
      }
    ?>
    <?php foreach ($data as $type => $rows): ?>
      <h2><?php echo $type?></h2>
      <ul>
      <?php foreach ($rows as $vehicleData):?>
        <li><?php echo $vehicleData['name'];?></li>
      <?php endforeach ?>
      </ul>
    <?php endforeach ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to retrieve data from several rows and then insert the results into
using jquery I need to retrieve an array from table cells, format the data
Ok, I need to store/retrieve a bit from a data table of 3.268.760 bits
I need to retrieve data from one table and use it to retrieve data
I need to retrieve data from an oracle table using a pl/sql stored procedure
Usually, I need to retrieve data from a table in some range; for example,
I need to retrieve distinct records from a column in a mysql table and
This one is doing my head in... I need to retrieve data from Oracle
I need to retrieve data from two tables. the first is a list of
this is my code where i need to retrieve data sent in POST: @play.db.jpa.Transactional

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.