We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50923
    • 137 Posts
    I am having problems with query in xPDO i have some custom table like this

    id | Name | useriD | bID | email


    In row i have something like this

    1 | Michael | 34 | 45 | [email protected]
    2 | Michael | 34 | 45 | [email protected]
    3 | John    | 34 | 45 | [email protected]
    4 | John    | 34 | 45 | [email protected]
    5 | John    | 34 | 45 | [email protected]
    6 | Jovan   | 34 | 45 | [email protected]
    7 | Peter   | 34 | 45 | [email protected]
    8 | Michael | 34 | 45 | [email protected]
    9 | Oliver  | 34 | 45 | [email protected]
    10 | Tataian | 34 | 45 | [email protected]


    When i try in phpmyadmin a simple query

    SELECT COUNT(`Name`) AS `Requests`, `Name` AS `Names`
     FROM `table`
     GROUP BY `Names`
     ORDER BY `Requests` DESC
     LIMIT 5


    I got proper results

    Requests | Names
    --------------------------
    3 | John
    3 | Michael
    1 | Jovan
    1 | Oliver
    1 | Peter


    But when i try something like this

    $result = $modx->query("SELECT COUNT(`Name`) AS `Requests`, `Name` AS `Names`
     FROM `table`
     GROUP BY `Names`
     ORDER BY `Requests` DESC
     LIMIT 5");
    if (!is_object($result)) {
       return 'No result!';
    }
    else {
    while($row = $result->fetch(PDO::FETCH_ASSOC))
     {
       print_r($row);
     }
    }


    The problem is that i dont know how to display this in table?
    [ed. note: miomir.dancevic last edited this post 8 years, 3 months ago.]
      <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>