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

    I’m trying to display text if nothing from the database was returned but I’m not quite sure what to use as the usually code isn’t working..

    <?php
    if ( isset($_GET['catid']) ) {
    
    $id = $_GET['catid'];
    
    $results = $modx->db->select("link_name,link_url,hitsout,submitter", "modx_links", "category = $id AND validated = '1'", "id", "");
    //
    // if ( $results == null) and if ( $results == '' ) do not work either.
    //
    if ( !$results ) 
        $text = 'There are no links at this time. ';
    
    }
    
    return $text;
    ?>
    
    • Garry Nutting Reply #2, 18 years ago
      Hi gaia,

      You can use:

      if ($modx->db->getRecordCount($results) == 0 ) {
          $text = 'There are no links at this time. ';
      }


      Hope that helps,

      Garry
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 10395
        • 96 Posts
        ah thanks garry, that worked perfectly ^_^