We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27305
    • 173 Posts
    Hmmm I’m trying to understand the api, I am doing a test to see if I can return all the alias information from the table modx_site_content

    <?php
    $results = $modx->db->select("alias", "modx_site_content", "", "alias", "60");

    echo $results;
    ?>

    It appears not to work and just shows resource 58, what am I doing wrong how to I show all the records?
      I made my first site with modx
      ------------------------
      Shopping blog
      Sky+ HD
      • 29181
      • 480 Posts
      I think that’s what PHP does when you try to output something like that. You can either loop through your rows with a loop of some kind, or if it is just for testing purposes as you say, I’m pretty sure
      print_r($results);


      will output the contents of $results. Alternatively, maybe something like:

      $total = mysql_num_rows ( $results );
      						echo "Your query found ".$total." results";
      						if($total>0):
      								while ( $row = mysql_fetch_assoc ( $results ) ) 
      								{				
      									echo "> ".$row['alias']"<br />";
      								}
      						endif;


      Something along those lines should give you something hopefully.

      Hope that helps!
      Taff





        Adrian Lawley: www.adrianlawley.com
        • 27305
        • 173 Posts
        cheers taf, if I use print_r($results); it still produces Resource id #58

        In my sql I got this from the documentation

        $results = $modx->db->select("field1, field2", "table", "field = value", "field to order by", "limit value");

        I have left the value "field = value" blank as I’m not sure what it does, is this why I get the error?
          I made my first site with modx
          ------------------------
          Shopping blog
          Sky+ HD
          • 27305
          • 173 Posts
          ah the problem was the field to order by, I left it blank and now it works

          Thanks for the help, I can carry on playing now.
            I made my first site with modx
            ------------------------
            Shopping blog
            Sky+ HD
            • 29181
            • 480 Posts
            Pleasure, glad you sorted it.

            On a sidenote, the URL in your signature has a l in the top level domain sending it to col.uk as opposed to co.uk

            :)

            Taff (with 2 "F"s as in the river in Wales)
              Adrian Lawley: www.adrianlawley.com
              • 28676
              • 136 Posts
              ah I never noticed that, will fix it now
                I made my first site with modx
                ------------------------
                http://www.shop-bright.com | Uk shopping blog