I think I just thought of a new way of approaching this.
Leave out the ranking, but put in an order by at the end, and use a union all.
That means that a search that matches both the AND and the OR will show up twice.
Now, since they're ordered, you just use a simple loop thing in your display:
$oldrow = array("");
while ($row = fetch_row($res)){
if (implode(":::",$oldrow)==implode(":::","$row)) { // gotta dupe
continue (); // or is that break? I think continue
}
}
Since all your dups will come out on top, you can just set some other switch that detects when the dups stop if you want to show the ORs in a different list from the ANDs...