\n";
$psql = "SELECT title,url,header1,projectid from jcaprojectdetail where active = 'yes' and `delete` = 'no' and frontpage = 'yes' ORDER BY RAND() limit 4";
$presult=$db->query($psql);
while ( $prow=$presult->fetch() ) {
$ptitle = $prow['title'];
$purl = $prow['url'];
$phead = $prow['header1'];
$projid = $prow['projectid'];
$psql2="select type,image from (select `primary` as type,image from imagedb where active = 'yes' and jobnumber = '$projid' order by RAND()) as subquery group by type";
$presult2=$db->query($psql2);
while ( $prow2=$presult2->fetch() ) {
$pcname = $prow2['image'];
$dir = "../imageassets/project-top/ch-level/$projid/$pcname";
};
$xtra .="