olha o erro:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND atividade LIKE '%Criações e Internet%' AND cidade LIKE '%Anápolis%' AND seto' at line 1
codigo do form da busca:
<?php
include "includes/conecta.php";
$sql_atividade = mysql_query("select * from atividade", $db);
$sql_cidade = mysql_query("select * from cidade", $db);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form action="busca.php" method="post" name="categoria">
<table width="100%" border="0">
<tr>
<td width="12%">Atividade:</td>
<td width="88%"><select name="atividade" id="categoria">
<option value="0"><
<Selecione o tipo>
></option>
<?php while($array = mysql_fetch_array($sql_atividade)) {?>
<option value="<?php echo $array['1']; ?>"><?php echo $array['1']; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td>Cidade:</td>
<td><select name="cidade" id="atividade">
<option value="0"><
<Selecione o tipo>
></option>
<?php while($array = mysql_fetch_array($sql_cidade)) {?>
<option value="<?php echo $array['1']; ?>"><?php echo $array['1']; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td>Setor:</td>
<td><input type="text" name="setor" id="setor" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Buscar" /></td>
</tr>
</table>
</form>
</body>
</html>
codigo do resultado da busca:
<?php
header("Content-Type: text/html; charset=ISO-8859-1", true);
require ("includes/conecta.php");
$sql_usu = "select id, empresa, atividade, cidade, setor from guia";
$atividade = $_POST['atividade'];
$cidade = $_POST['cidade'];
$setor = $_POST['setor'];
if($atividade || $cidade || $setor) {
$sql_usu .= " AND atividade LIKE '%$atividade%' AND cidade LIKE '%$cidade%' AND setor LIKE '%$setor%'";
}
$sql_usuarios = mysql_query($sql_usu) or die( mysql_error() );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?php
if (mysql_num_rows($sql_usuarios) > 0)
while ($vetor=mysql_fetch_array($sql_usuarios)) { ?>
<table width="100%" border="0">
<tr>
<td><?php echo $vetor['empresa'] ?></td>
</tr>
</table>
<?php } ?>
</body>
</html>
banco de dados:
create table atividade (
id int(11) not null auto_increment,
nome varchar(255) default null,
PRIMARY KEY(id)
);
create table cidade (
id int(11) not null auto_increment,
cidade varchar(255) default null,
PRIMARY KEY(id)
);
create table estado (
id int(11) not null auto_increment,
estado varchar(255) default null,
PRIMARY KEY(id)
);
create table guia (
id int(11) not null auto_increment,
empresa varchar(255) default null,
atividade varchar(255) default null,
cidade varchar(255) default null,
estado varchar(255) default null,
setor varchar(255) default null,
PRIMARY KEY(id)
);
quem puder me ajudar a fazer com que esta busca funcione beleza ficarei grata