Hello All,
I am trying hard to do the following and would GREATLY appreciate some help:
I have a database table with a field for name and a field for resources that person offers, among other things. One person may have resources to offer in several different departments or for several different projects. Right now, when I display the data in a table sorted by department, or project, or whatever, I get the name along with the data even if it is repeated. (I am using Dreamweaver MX 2004 and using Repeat Region to show the table with the data in it.) So for instance I get rows like this:
John Doe Chemistry
John Doe Biology
John Doe Pharmacology
Flo Schmoe Chemistry
What I'd like to do is exclude duplicates after the first instance of a given name, so my displayed data looks like this instead:
John Doe Chemistry
Biology
Pharmacology
Flo Schmoe Chemistry
Can't seem to figure out how to get this going.
I know that when I loop through my data, I need to keep track of the person's name. Then when the next record rolls around, I need to check the name with the name for this new record. If they match, then I have a duplicate name and I need to skip over the code that displays the name. If they don't match, then I need to show the name. I will remember to set the name to the current name before I loop to the next record, of course...
Can anyone give me a little bit of code as an example of how I can do this? Since i am a newbie, I sort of get what I need to do but not how I would go about it. How does this fit in with the code I displayed below?
A snippet of code I could modify and run with would be extremely helpful; can't seem to find a solution thus far.
Thanks very much,
Bob
P.S. Code sample below:
The recordset:
$colvar3_resources_all = "all";
if (isset($GET['restype'])) {
$colvar3_resources_all = (get_magic_quotes_gpc()) ? $GET['resource_type'] : addslashes($GET['resource_type']);
}
$colvar2_resources_all = "all";
if (isset($GET['project'])) {
$colvar2_resources_all = (get_magic_quotes_gpc()) ? $GET['project'] : addslashes($GET['project']);
}
$colvar_resources_all = "all";
if (isset($GET['department'])) {
$colvar_resources_all = (get_magic_quotes_gpc()) ? $GET['department'] : addslashes($GET['department']);
}
mysql_select_db($database*dbset, $dbset);
$query_resources_all = sprintf("SELECT FROM resource WHERE '%s' = 'all' AND '%s' = 'all' AND '%s' = 'all' ORDER BY name ASC, resource.recordid ASC", $colvar_resources_all,$colvar2_resources_all,$colv
ar3_resources_all);
$resources_all = mysql_query($query_resources_all, $****dbset) or die(mysql_error());
$row_resources_all = mysql_fetch_assoc($resources_all);
$totalRows_resources_all = mysql_num_rows($resources_all);
The table itself:
<?php do { ?>
<tr class="****data">
<td><?php echo $row_resources_all['name']; ?></td>
<td><?php echo $row_resources_all['project']; ?></td>
<td><?php echo $row_resources_all['department']; ?></td>
<td><?php echo $row_resources_all['resource']; ?></td>
<td><?php echo $row_resources_all['resource_type']; ?></td>
<td><?php echo $row_resources_all['function']; ?></td>
<td><?php echo $row_resources_all['online_info']; ?></td>
</tr>
<?php } while ($row_resources_all = mysql_fetch_assoc($resources_all)); ?>
</table>