Wow - thanks a lot man - I get what the code is trying to do but somehow it doesn't work.
The column in my table is "tercio_tf"
Here is my "select" coding;
<p><b>Donde?
<select name="tercio_tf">
<option value=nothing>Da igual</option>
<option value="s">Tenerife Sur</option>
<option value="n">Tenerife Norte</option>
<option value="st">Santa Cruz /La Laguna</option>
</select>
And here is my php script;
$sql = "
SELECT
*
FROM
table
";
if( !emtpy($POST['tercio_tf']) ) $sql .= " WHERE ";
if( !emtpy($POST['tercio_tf']) && $POST['tercio_tf'] != 'nothing' ) $sql .= " tercio_tf LIKE '%" . $POST['tercio_tf'] . "%' ";
$result = mysql_query($sql);
I cut it down to one line just to check the errors as I couldn't get it to work - but unfortunately I still can't get it to work.
I tried "" around the nothing in the select option section, and I tried putting $ infront of the variable inside the &_POST[] bit but it doesn't work. I even put curly brackets around the $result=mysql_query bit but nothing helps.
I get the error message;
Fatal error: Call to undefined function: emtpy() in /home/wingates/wingateschool-www/projects/tenercoche/buscartest.php on line 23
Here is my original code which works fine as long as you select specific values;
$result = mysql_query("select * from tenercoche_privado where marca='$marca' and
modelo LIKE '{$modelo}%' and
tercio_tf='$tercio_tf' and
combustible = '$combustible' and
techo = '$techo' and
caja_cambios = '$cambios' and
edad <= '$edadmax' and
kms <= '$kmmax' and
potencia >= '$cvmin' and
'$precio_min' < precio < '$precio_max' order by precio ")
or die (mysql_error() );
Any ideas?
I really appreciate your help - this would take me years otherwise!!
Thanks.
Jon