linha 1 da tabela campo conteudo "1"
linha 2 da tabela campo conteudo "1 2"
linha 3 da tabela campo conteudo "1"
linha 4 da tabela campo conteudo "1 2 3"
linha 5 da tabela campo conteudo "2"
linha 6 da tabela campo conteudo "3"
linha 7 da tabela campo conteudo "1"
// ACREDITO QUE A SOLUÇÃO POSSA SER ALGOM COMO Strpbrk OU strstr !
Preciso filtrar a tabela da seguinte forma. Se campo conteudo contem 2 ele é listado. e no resultado deveria aparecer as linhas 2, 4, e 6.
o codigo abaixo só permite que eu filtre um numero inteiro. qual a mudança que dever ser feita? obigado!
Linha que deve gerar a pesquisa que estou com duvida
$query .= " AND p.conteudo=" . $sql->quote ( $conteudo );
abaixo codigo completo.
if ( $cgi->getValue ( "op" ) == "search" )
{
$pt = $cgi->getValue ( "pt" );
$pp = $cgi->getValue ( "pp" );
$pb = $cgi->getValue ( "pb" );
$pl = $cgi->getValue ( "pl" );
$po = $cgi->getValue ( "po" );
$pp_min = $cgi->getValue ( "pp_min" );
$pp_max = $cgi->getValue ( "pp_max" );
$conteudo = $cgi->getValue ("conteudo");
$query = "
SELECT
p.id AS id,
p.propertyoption AS propertyoption,
p.propertyprice AS propertyprice,
p.propertyaddress AS propertyaddress,
pl.propertylocation AS propertylocation,
ps.propertystatus AS propertystatus,
pt.propertytype AS propertytype,
p.propertyref AS propertyref,
p.propertybedrooms AS propertybedrooms,
p.propertyphoto1 AS propertyphoto1,
p.propertyphoto2 AS propertyphoto2,
p.propertyphoto3 AS propertyphoto3,
p.propertyphoto4 AS propertyphoto4,
p.shortdescription AS shortdescription,
p.longdescription AS longdescription,
p.virtualtour AS virtualtour,
p.conteudo AS conteudo
FROM
" . $property_table . " p
INNER JOIN
" . $propertytypes_table . " pt ON (p.propertytype=pt.id)
INNER JOIN
" . $propertylocations_table . " pl ON (p.propertylocation=pl.id)
INNER JOIN
" . $propertystatus_table . " ps ON (p.propertystatus=ps.id)
WHERE
p.propertyshow=1
";
if ( $pt != "" )
$query .= " AND p.propertytype=" . $sql->quote ( $pt );
if ( $pp_min != "" )
$query .= " AND p.propertyprice>=" . $sql->quote ( $pp_min );
if ( $pp_max != "" )
$query .= " AND p.propertyprice<=" . $sql->quote ( $pp_max );
if ( $pb != "" )
$query .= " AND p.propertybedrooms>=" . $sql->quote ( $pb );
if ( $pl != "" )
$query .= " AND p.propertylocation=" . $sql->quote ( $pl );
if ( $po != "" )
$query .= " AND p.propertyoption=" . $sql->quote ( $po );
if ( $conteudo != "" )
$query .= " AND p.conteudo=" . $sql->quote ( $conteudo );
// set the query ordering
if ( isset ( $property_search_order ) && $property_search_order != "" )
$query .= "ORDER BY p." . $property_search_order . " " .
( "a" == strtolower ( substr ( $property_search_ordering, 0, 1 ) ) ?
"ASC" : "DESC" );
$results = $sql->execute ( $query, SQL_RETURN_ASSOC );
$total_results = sizeof ( $results );
Edição feita por: inascimentojr, 05/09/2009, 14:56.