I think I understand what the steps need to be taken, I'm just having difficulties getting it in my code.
Oh... get_results() is just part of the class I'm using. In fact I could rewrite the code like this:
if ($type == 't1') {
$SRCHwhere = "table1 WHERE orgType='association' AND NameX";
$foundname = "NameX";
} elseif ($type == 't2') {
$SRCHwhere = "table2 WHERE NameY";
$foundname = "NameY";
} elseif ($type == 't3') {
$SRCHwhere = "table3 WHERE NameZ";
$foundname = "NameZ";
if($foundResults = $db->get_results ("SELECT * FROM ".$SRCHwhere." LIKE '%".$srch."%'"))
{
foreach ( $foundResults as $fr )
echo "<tr>
<td>".$fr->$foundname."</td>
</tr>";
}
} else {
// nothing found do something else, like run another query.
}
But it's starting to look a bit convoluted, doesn't it?