We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41710
    • 18 Posts
    I had a snippet that was working fine in Evo that I'd like to move over to Revo, however it doesn't work anymore. Everything works fine in Evo but when I put it into the Revo version of the site it breaks it.

    Here is what is was:

    // Connect to the database
    $myusadb= new DBAPI();
    $myusadb->connect($host='localhost',$dbase=''####', $uid=''####',$pwd='####');
    
    // Get all the data from the content table
    $result = mysql_query("SELECT * FROM `modx_site_content` WHERE `parent` = 7 ORDER BY pub_date DESC LIMIT 3") // put it into an array
    or die(mysql_error());  
                    echo "<ul>"; 
    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
    
                    // Print out the contents of each row into a table
                    echo "<li>"; 
                    echo " <a href=\""; 
                    echo $row['content'];
                    echo "\" target=\"_blank\">"; 
                    echo $row['description'];
                    echo "</i> - "; 
                    echo $row['pagetitle']; 
                    echo "</a>"; 
                    echo "</li>"; 
    }
                    echo "</ul>";
    $myusadb->disconnect();


    Thanks for any help!
      • 4172
      • 5,888 Posts
      you can just use getResources:

      <ul>
      [[getResources? 
      &parents=`7` 
      &includeContent=`1`
      &sortby=`pub_date` 
      &sortdir=`DESC` 
      &limit=`3`
      &tpl=`@INLINE <li> <a href="[[+content]]" target="_blank"> [[+description]]</i> - [[+pagetitle]]</a></li>  `
      ]]
      </ul>
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 41710
        • 18 Posts
        This is actually from a different MySQL database than the one this install of ModX is using - same server, different install of ModX.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 41710
            • 18 Posts
            Okay, thank you for the link. I've been able to get it connected and to display the number of rows (which is what the example shows) however I can't figure out how to grab data from the table and print it until all the rows have been printed.
              • 41710
              • 18 Posts
              I'm sorry I'm not a programmer, but I really can't figure out how to get this to do this part:

              // keeps getting the next row until there are no more to get
              while($row = mysql_fetch_array( $result )) {

              // Print out the contents of each row into a table
              echo "<li>";

              etc...

              Thanks so much!
                • 41710
                • 18 Posts
                Okay, I've tried
                echo $results->get('content');

                But it's not showing anything. Please help!
                  • 41710
                  • 18 Posts
                  Well, I got it working using this:

                  https://forums.modx.com/index.php?topic=67690.0