Simon, I don't understand question 2.
The first question's fairly easy.
You need to break your query up into the different clauses. So you'll have part one be something like
$query="select tid,keyword from search_table";
Part two is your where, and this is where it gets tricky.
Let's say you have three sets of radio buttons on your page. Call each set 1, 2, or 3.
(sample code:
<input type="radio" name="rad1" checked value="and" />and
<input type="radio" name="rad1" value="or" />or
<input type="text" name="text1" />
)
So what you want to do is to build a routine that concatenates the result of each set of and/ors into your query. You repeat this for as many text boxes with and/ors that you're going to have, obviously changing the number from 1 to whatever.
(sample code:
if($text1) {
$query=$query." ".$rad1." ".$text1;
}
)
So it tests to make sure there's something in the text box, and then it concatenates everything on to the end.
Obviously there's more efficient ways to do it using loops and an array, but this is the general theory, and it will get you started.