We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24969
    • 120 Posts
    Hi guys,
    Me again, I have a page displaying the various breedings of the dogs,
    <?php
    $sql="SELECT tbreeding . * , sire.callname AS sire_callname, dam.callname AS dam_callname, sire.regname AS sire_regname, dam.regname AS dam_regname
    FROM `tblbreeding` tbreeding
    LEFT JOIN `tbldogs` sire ON sire.dog_id = tbreeding.sireFK
    LEFT JOIN `tbldogs` dam ON dam.dog_id = tbreeding.damFK
    LIMIT 0 , 1000";
    $rs=$modx->db->query($sql);
    $resultArray = $modx->db->makeArray($rs);
    
    //var_dump($resultArray);//for debugging
    
    if (count($resultArray)>0){
        $output = '';
         foreach($resultArray as $item){
              $params['Sire_callname']=$item['sire_callname'];
              $params['Dam_callname']=$item['dam_callname'];
              $params['id']=$item['id'];
              if($item['show']){
                        $params['show'] = "checked";
              } else {
                        $params['show'] = "";
              }
              $output.=$modx->parseChunk('Litters', $params, '[+', '+]');
         }
    }
    return($output);
    ?>

    along with the code to update said table,
    <?php
    function breeding( &$fields ){
         global $modx;
         $dbTable=array();
         $table = $modx->getFullTableName( 'tblbreeding');
         $dbTable['id']=$fields['id'];
         $dbTable['show']=$fields['show'];
    
    
         $dbQuery = $modx->db->insert($dbTable, $table );
         return true;
    }
    ?>


    How do I call the function ’breeding’ passing it the required fields.

    Eventually I’m hoping that this process will become easier, and thus my questions will become fewer and fewer. grin
      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
      • 24969
      • 120 Posts
      Nothing.... Please guys/gals, I really need to get this working.
        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
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        I’m not sure what your question is. I didn’t see a question mark... what exactly is the problem you’re having?
          • 16183
          • 1,390 Posts
          Quote from: Everett at Aug 30, 2009, 10:55 AM

          I’m not sure what your question is. I didn’t see a question mark... what exactly is the problem you’re having?

          I think this is the question....

          Quote from: rhyno at Aug 28, 2009, 08:44 PM

          How do I call the function ’breeding’ passing it the required fields.

          :D
            • 24969
            • 120 Posts
            Sorry... es you are correct, how do I call the function ’breeding’ while passing it the required variables?
              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
              • 9207 ☆ A M B ☆
              • 2,475 Posts
              If I were you, I’d put your "breeding" function into a Snippet, and put that Snippet onto its own page. Then post your form to that page. Get the values from the form by reading the values from the $_POST array... so your Snippet would look something like this:

                 global $modx;
                   $dbTable=array();
                   $table = $modx->getFullTableName( 'tblbreeding');
                   $dbTable['id']=$_POST['id'];
                   $dbTable['show']=$_POST['show'];
              
                   $dbQuery = $modx->db->insert($dbTable, $table );
                   return true;
                • 24969
                • 120 Posts
                Thanks Everett, I will test this out later today... Stay Tuned wink
                  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
                  • 24969
                  • 120 Posts
                  I keep getting:
                  Fatal error: Call to undefined function adding faq() in E:\wamp\www\Chrys-haefen\assets\snippets\eform\eform.inc.php on line 378


                  huh
                  I put the snippet above into its own snippet thingy, then I called it from the page. What am I doing wrong?
                  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
                    • 9207 ☆ A M B ☆
                    • 2,475 Posts
                    That error is from eForm... so you should look there. First test this without eForm.

                    Make a normal form with the data you need to collect (e.g. "id" and "show"):

                    <form action="http://somesite.com/form_handler_page" method="post">
                    Id:
                    <input type="text" name="id" />
                    <br />
                    Show:
                    <input type="text" name="show" />
                    </form>
                    


                    Note that you can use a MODx tag for the action page, e.g. [~123~] if the form handler page is on page 123.

                    Then on the other page (#123 in this example), put your Snippet call... again, your Snippet call will read data from the $_POST array:
                    [!YourSnippet!]

                    YourSnippet contains this code:
                     global $modx;
                         $dbTable=array();
                         $table = $modx->getFullTableName( 'tblbreeding');
                         $dbTable['id']=$_POST['id'];
                         $dbTable['show']=$_POST['show'];
                    
                         $dbQuery = $modx->db->insert($dbTable, $table );
                         return true;



                    Do you see how this works? The form collects the data, then posts it to the form handler, which reads the data and then populates the db.
                      • 24969
                      • 120 Posts
                      ok thanks, I will try it out.
                        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