We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24969
    • 120 Posts
    Like the title says, does MODx support a function to clear the chunk of all data prior to repopulating it? huh
      The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

      -Albert Einstein (1879 - 1955)

      Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Context would be useful; having no idea what you are trying to do makes it difficult to offer any suggestions.
        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
        • 24969
        • 120 Posts
        Sorry Susan,
        <?php
        //list out all the dogs in the system
        $output='';
        switch($_REQUEST[breed]){
             case goldens:
                  $goldens= sprintf("
                      SELECT *
                      FROM tbldogs
                      WHERE breedID=87
                      ORDER BY callname;");
                  $rsetg=$modx->db->query($goldens);
                  if ($modx->db->getRecordCount($rsetg) > 0) {            
                    while ($row = $modx->db->getRow($rsetg)) {
                      $params['id']=$row['dog_id'];
                      $params['callname']=$row['callname'];
                      $params['regname']=$row['regname'];
                      $output.=$modx->parseChunk('List Dogs', $params, '[+', '+]');
                    }
                   }
                  return($output);
                  break;
             case cavaliers:
                  $cavaliers=sprintf("
                      SELECT *
                      FROM tbldogs
                      WHERE breedID=51
                      ORDER BY callname;");
                  $rsetc=$modx->db->query($cavaliers);
                   
                  if($modx->db->getRecordCount($rsetc) >0){
                    while($foo = $modx->db->getRow($rsetc)){
                      $params['id']=$row['dog_id'];
                      $params['callname']=$row['callname'];
                      $params['regname']=$row['regname'];
                      $output.=$modx->parseChunk('List Dogs', $params, '{+','+]');
                    }
                   }
                  return($output);
                  break;
        }
        
        function update( &$fields ){
        }
        function add(&$fields){
        }
        function delete(&$fields){
                  echo $fields;
                 return($message );
        }
        // check for a valid submission
        if($_REQUEST['Submit']){
            $message = delete($_REQUEST);
            echo $message."<br />";
        }
        ?>


        However, in my chunk for the breed cavaliers, I get 15 rows with a value of null.... So I was wondering if I needed to clear the chunk out before populating it again....
          The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

          -Albert Einstein (1879 - 1955)

          Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
          • 3749
          • 24,544 Posts
          It looks like your not changing $rsetc and $rsetg in your loops so you’re getting the same row each time.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 24969
            • 120 Posts
            It looks like your not changing $rsetc and $rsetg in your loops so you’re getting the same row each time.

            Where are you seeing this? I know I am a noob when it comes to programming, but I think I’ve done that.... huh
              The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

              -Albert Einstein (1879 - 1955)

              Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
              • 10487 MODX Staff
              • 1,535 Posts
              Garry Nutting Reply #6, 17 years ago
              This looks wrong to me, with your usage of $foo and your placeholder prefix in the parseChunk() call:
              if($modx->db->getRecordCount($rsetc) >0){
                 while($foo = $modx->db->getRow($rsetc)){
                	$params['id']=$row['dog_id'];
                      $params['callname']=$row['callname'];
                      $params['regname']=$row['regname'];
                      $output.=$modx->parseChunk('List Dogs', $params, '{+','+]');
                 }
              }

              It should be, from what I can tell:
              if($modx->db->getRecordCount($rsetc) >0){
                 while($foo = $modx->db->getRow($rsetc)){
                	$params['id']=$foo['dog_id'];
                      $params['callname']=$foo['callname'];
                      $params['regname']=$foo['regname'];
                      $output.=$modx->parseChunk('List Dogs', $params, '[+','+]');
                 }
              }
                Garry Nutting
                Senior Developer
                MODX, LLC

                Email: [email protected]
                Twitter: @garryn
                Web: modx.com
                • 3749
                • 24,544 Posts
                Never mind my comment. I was forgetting that getRow() increments the row pointer.

                I think Garry is right.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 24969
                  • 120 Posts
                  Thank you gary,
                  I forgot I created $foo.... My bad.
                    The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.

                    -Albert Einstein (1879 - 1955)

                    Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635