Thanks for the replys... I have come up with the following query which returns the following result set.
Query:
SELECT d.callname, d.regname, d.sex, i.filelocation, i.description, (
SELECT callname
FROM tbldogs d2
WHERE d2.litter = d.dog_id
) AS mated
FROM tbldogs d, tblimages i
WHERE d.litter != '0'
AND d.breedID =87
AND i.dogfk = d.dog_id
AND use_pict = 'Y'
ORDER BY sex
Results:
callname regname sex filelocation description mated
Laila Chrys-haefen Floatlikeabutafly Female images/dogs/goldens/laila/layla-stackedsm.jpg Laila Stacked Ivan
Marley Chrys-haefen Don’t Rock T’Boat Female images/dogs/goldens/marley/marleystackedsm.jpg Marley Stacked Rigger
Rigger Chrys-haefen Rigger Folkins Male images/dogs/goldens/rigger/riggersm.jpg Rigger Marley
Ivan Guldakra's Ivan Lendl Male images/dogs/goldens/ivan/ivan-1-year-oldsm.jpg Ivan Laila
This is what I need for my client.... But I need to store the resulting query in parameters that relate to sire and dam....
Sire would be Rigger.
Dam would be Laila.
My snippet looks like this.
<?php
$output = '';//create variable for holding the output
$sql = $modx->db->query( 'SELECT d.callname, d.regname, i.filelocation, i.description, (
SELECT callname
FROM tbldogs d2
WHERE d2.litter = d.dog_id
) AS mated
FROM tbldogs d, tblimages i
WHERE d.litter != '0'
AND d.breedID =87
AND i.dogfk = d.dog_id
AND use_pict = 'Y'
ORDER BY sex
LIMIT 0 , 1000');//define the DB query, in this case the table is named 'tbldogs'
$resultArray = $modx->db->makeArray($sql);//put it into an array
foreach($resultArray as $item) //go through each record in the array
{//start looping through the data array
$params['sire']=$item['regname'];//set the placeholders, the $params sets the name of the placeholder, the $item is the field name from the DB table
$params['sirecallname']=$item['callname'];
$params['dam']=$item['regname'];
$params['damcallname']=$item['callname'];
$params['photo']=$item['filelocation'];
$params['alt_text']=$item['description'];
$output.=$modx->parseChunk('Golden Litters', $params, '[+', '+]');//define the chunk name and process the content
}//finish looping through the data array
return $output;//now return the output from the processed chunk
?>
How can I store the sire and dam parameters correctly??