We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 97
    • 5 Posts
    Hello! I am new to ModX and have only been working with it for about....a week.

    I am trying to access some very simple data I have placed into a database to be spit into a page and modified with jquery.

    I have looked all over google, all over this site, and tried for the last 3 hours or so to figure this out, but I am just not having any luck. The table is in the modX database (don’t know if this is the right way to do this or not?) so it shouldn’t have any permission issues.

    Here is my code:
    <?php
    $output = '';
    
    $modx->db->connect();
    
    $sql = $modx->db->query( 'SELECT * FROM `businesses` ORDER BY ID');
    
    $resultArray = $modx->db->makeArray( $sql ); 
    
    foreach($resultArray as $item)
    {
         $output.=$item;
         $params['name']=$item['businessName'];
         $params['url']=$item['businessURL'];
         $params['category']=$item[businessCategory'];
         $params['description']=$item[businessDescription'];
         $output.=$modx->parseChunk('businessTpl', $params, '[+', '+]');
    }
    return $output;
    ?>
    


    This code is more or less taken from one of the modX wiki pages. I have tried just echoing this data, among other things, and it never really works at all. I tried removing all of the parameters to just spit out what is in the array, but then all it said was array,array,array,array,array,array. I’m confused....I’m also a PHP newb (I come from c#/asp.net) so I’m sure that is going against me as well, but the code above looks sound to me....

    I hope someone can shed light on this, and help me and others that may come across this in google.

    Thanks!
    • Quote from: ganeshXL at Jul 03, 2010, 09:58 AM

      Hmm, that example seems to have some unclosed / unmatched ’ somewhere.

      $params['category']=$item[businessCategory'];

      Should be [tt]$item[businessCategory’][/tt]
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 97
        • 5 Posts
        I feel like an idiot. Thanks for pointing out the blatantly obvious to me! Seriously appreciate it. Must have been the late night hours I’ve been using to work on this lol.

        Now to figure out how to paginate it......

        Thanks again!
        • I once spent three hours finding out I had mistyped ’src’ as ’scr’ in some simple mark up.......
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 97
            • 5 Posts
            Hah, ya I can’t count how many times I’ve done silly things like that. Thanks to all who responded. The information was very valuable.