We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24969
    • 120 Posts
    $id=$_REQUEST['dogid'];
    if(isset($id)){
    	$output='';
    	$sql = sprintf("
                  SELECT callname, regname
                  FROM tbldogs
                  WHERE dog_id=%d",
                  (int)$id);
    	$rset=$modx->db->query($sql);
    	if ($modx->db->getRecordCount($rset) > 0) {
    		while ($row = $modx->db->getRow($rset)) {
    			$params['callname']=$row['callname'];
    			$params['regname']=$row['regname'];
    			$output.=$modx->parseChunk('Gallery', $params, '[+', '+]');
    		}
    	}
            $sql = sprintf("SELECT filelocation, description
    	FROM `tblimages`
    	WHERE use_pict = 'N'
    	AND dogFK=%d",
                  (int)$id);
    	$pic=$modx->db->query($sql);
    	if($modx->db->getRecordCount($pic) > 0) {
    		while($row=$modx->db->getRow($pic)){
    			$params['pic']='<img src="assets/'.$row['filelocation'].'" alt="'.$row['description'].'"/>';
    			$output.=$modx->parseChunk('Gallery', $params, '[+', '+]');
    		}
    	}
    	$pd = sprintf("SELECT filelocation, file_description description FROM tblpedigree WHERE dogID=%d", (int)$id);
    	$ped=$modx->db->query($pd);
    	if($modx->db->getRecordCount($ped) >0){
    		while($row=$modx->db->getRow($ped)){
    			$params['pedigree']='<img src="assets/'.$row['filelocation'].'" alt="'.$row['description'].'"/>';
    			$output.=$modx->parseChunk('Gallery', $params, '[+','+]');
    		}
    	}
    
    	return $output;
    }


    Is my snippet, I am not sure why my pictures and name come out but the pedigree information is not I must be doing something really stupid because I can’t seem to find it... Can you guys/gals have a look and let me know where I’ve fat fingured my code?
    Specifically
    $pd = sprintf("SELECT filelocation, file_description description FROM tblpedigree WHERE dogID=%d", (int)$id);
    	$ped=$modx->db->query($pd);
    	if($modx->db->getRecordCount($ped) >0){
    		while($row=$modx->db->getRow($ped)){
    			$params['pedigree']='<img src="assets/'.$row['filelocation'].'" alt="'.$row['description'].'"/>';
    			$output.=$modx->parseChunk('Gallery', $params, '[+','+]');
    		}
    	}
    
    	return $output;
    That is where I think i’ve screwed it up...

    And I’m not sure why but my page shows the dogs name more than once per picture. http://modx.chrys-haefen.com/index.php?id=32&dogid=129 I would Really like it if some one could shed some light on this as well.
    Thanks for the help.
      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
      No help?!?! Common please?
        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
        • 7923
        • 4,213 Posts
        Quote from: rhyno at Sep 15, 2009, 07:08 AM
        SELECT filelocation, file_description description FROM tblpedigree WHERE dogID=%d
        Quote from: rhyno at Sep 15, 2009, 07:08 AM

        And I’m not sure why but my page shows the dogs name more than once per picture.

        For the first question, you are renaming file_description column to description for the result set, is that on purpose? Are the column names and table name right?

        And... What does the queries return? Try to debug with print_r($modx->db->makeArray($rset)) and if you are just expecting one result for the query, add LIMIT to that query.

        Check for MySQL errors in your log files and try echo $modx->db->getLastError()


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 24969
          • 120 Posts
          Thanks for the reply Dozer,
          Yes I know I am renaming the column, and yes it is on purpose. The column names and the table name is correct.
          The tables hold the file location of the name of the file....ie)
          SELECT filelocation, file_description description FROM tblpedigree WHERE dogID=1 LIMIT 0, 30 ;
          Rows: 1
          filelocation 	description
          images/dogs/goldens/jerry/jerry_pedsm.jpg 	Jerry's Pedigree


            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