We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44437
    • 74 Posts
    Hi guys,

    I have a database table that has in almost all of the vehicles ever made from 2016 until 1960s. Thats over 63000 records.

    For example: I have fields like


    I want to write a query that will return the vehicle make only once and to ignore any other the vehicle make if it is found again.

    example
    Audi
    Abarth
    Suzuki
    Toyota
    etc

    Then once I have those names, I want to use them as a filter. Whenever a user selects a vehicle make, I want to search the database table and return all of its models once

    example
    Make: Suzuki

    Model
    Swift
    Vitara
    Jimny
    etc

    Here is what I have

    $sql = "SELECT model_make_id FROM modx_02_models";
    foreach ($modx->query($sql) as $row) {
        $output .= $row['model_make_id'] .'<br/>';
    }
    return $output;


    And it is return everything? How can do the above and what the best most efficient way of doing this? Because if several or 100 of users make these queries often, won't it affect the server's performance?
      • 3749
      • 24,544 Posts
      Please don't double post.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting