Well, you can always use a for() loop and increment numbers sequentially to automatically build a query.
What are the values going to be like? Are the fields actually enumerated as such, i.e. a constant keyword appended with a number? If so, a simple PHP for() loop would do the trick:
$query = 'SELECT * FROM `table` WHERE ';
for($i = 1; $i < 30; $i++)
$query .= '`foo' . $i . '` LIKE \'foo' . $i . '\' AND ';
$query = rtrim($query, ' AND');
If you exaggerated the simplicity of the structure/query in order to explain it, then more complicated loops or alternate methods might still be able to help you. If nothing else, better start a-typing! 😉