display based on group. I want to display in the way that same project group of contact will display the project name once only.
For example:
ProjectA
Contact1
Contact2
Contact3
Project B
Contact1
Contact2.
But the code I have didn't work as it display as
ProjectA
Contact1
ProjectA
Contact2
ProjectA
Contact3
Project B
Contact1
Project B
Contact2
Any idea. I am using smarty with adodb
<?php
require_once("./config.inc.php");
lib_login_protect_page_heirarchy_group(4);
$tpl = new Template_API();
$tpl->setTemplate("customer_contact.tpl");
$db = NewADOConnection("$database_type");
$db->PConnect("$host", "$user", "$password", "eontap") or die("Unable to connect!");
$db->SetFetchMode(ADODB_FETCH_ASSOC);
$sql = "SELECT * from view_contact_list where projectdescription <> 'Infrastructure'";
$rs = $db->Execute($sql);
$i=0;
$tmp_projectid = "";
while (!$rs->EOF) {
$row = array(
'customer' => $rs->fields['projectdescription'],
'contactgroup' => $rs->fields['contactgroup'],
'priority' => $rs->fields['priority'],
'name' => $rs->fields['name'],
'state' => $rs->fields['name'],
'jobtitle' => $rs->fields['jobtitle'],
'workphone' => $rs->fields['workphone'],
'workext' => $rs->fields['workext'],
'mobilephone' => $rs->fields['mobilephone'],
'faxnumber' => $rs->fields['faxnumber'],
'pagernumber' => $rs->fields['pagernumber'],
'emailaddress' => $rs->fields['emailaddress']);
$fldprojectid = $row['customer'];
if ($tmp_projectid <> $fldprojectid) {
$tmp_projectid = $fldprojectid;
$customer_header = "On";
$tpl->assign('customer_header', $customer_header);
$tpl->assign('projectid', $fldprojectid);
}
else {
$customer_header = "Off";
$tpl->assign('customer_header', $customer_header);
}
$rs->MoveNext();
$result[$i++] = $row;
}
$db->Close();
$tpl->assign('tpl_result', $result);
$tpl->assign('title', 'Customers Contact List');
$tpl->displayTemplate();
?>
Template
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
<h1>{$title}</h1>
<table cellpadding=2 cellspacing=1 border=0 width=80%>
{section name="i" loop=$tpl_result}
{cycle values="#FFFFFF,#EAECEF" assign="row_color"}
{if $customer_header == "On"}
<tr>
<th colspan="10">{$tpl_result.customer}{$customer_header}{$projectid}</th>
</tr>
{/if}
<tr bgcolor="{$row_color}">
<td>{$tpl_result.contactgroup}</td>
<td>{$tpl_result.priority}</td>
<td>{$tpl_result.name}</td>
<td>{$tpl_result.jobtitle}</td>
<td>{$tpl_result.workphone}</td>
<td>{$tpl_result.workext}</td>
<td>{$tpl_result.mobilephone}</td>
<td>{$tpl_result.faxnumber}</td>
<td>{$tpl_result.pagernumber}</td>
<td>{$tpl_result[i].emailaddress}</td>
</tr>
{sectionelse}
<tr>
<td colspan="7">No Records</td>
</tr>
{/section}
</table>
</center>
</body>
</html>