Another method, dont know how suitable it is for this case but the WHERE statement is very flexible as you can assign alot of diffrent values to the $argX variables.
(Ex you could assign the values with $GET/$POST/$_REQUEST, but then you should consider useing mysql_real_escape_string() to make sure no unwanted char's sneak into your WHERE statement.)
$arg1 = "t1.Active=1";
$arg2 = "t3.OnStage=0";
$arg3 = "t3.Active=1";
$arg4 = "t1.ID <> 58";
$arg5 = "t3.ShowPos = 0";
$query = sprintf("SELECT something FROM anytable t1, anytable2 t2, anytable3 t3
WHERE %s AND %s AND %s AND %s AND %s", $arg1, $arg2, $arg3, $arg4, $arg5);
$result = mysql_query($query);
I guess this could also be built into a function where $arg1..5 is parameters and $result is returned. Something like this, i havent testet it but i think it should work:
function my_query($arg1,$arg2,$arg3,$arg4,$arg5)
{
$query = sprintf("SELECT something FROM anytable t1, anytable2 t2, anytable3 t3
WHERE %s AND %s AND %s AND %s AND %s", $arg1, $arg2, $arg3, $arg4, $arg5);
$result = mysql_query($query);
return $result;
}
// some code
$result2=my_query("t1.Active=1","t3.OnStage=0","t3.Active=1","t1.ID <> 58","t3.ShowPos = 0");
//Or you could do
//$result2=my_query($a1,$a2,$a3,$a4,$a5);
//and then assign values to $a1..5 as needed in the WHERE as in the example above
while ($row=mysql_fetch_array($result2))
{
// some code
}
// more code