Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

MySQLi Where Like syntax

$
0
0
Hello! I have a problem with MySQLi:
if ($caut=="CodOferta")
        $commmand = $connec->query("SELECT * FROM ".$l." WHERE ".$caut."='".$_POST['cautare']."'") or die($mysqli->error.__LINE__);
else
{
	$commmand = $connec->query("SELECT * FROM ".$l." WHERE '".$caut."' LIKE '%".$_POST['cautare']."%'") or die($mysqli->error.__LINE__);
	echo $l."</br>";
}
if($commmand->num_rows > 0) 
{ ... }


When $caut = "CodOferta" it show the results, but when is not equal doesn't show me nothing!
I tried to in the else for $command to put
"SELECT * FROM ".$l." WHERE '".$caut."' LIKE '%test%'"
but still nothing.
$l is a variable and it's change his value every time( all code is in a while) and in one of tabels I have this:
Cod oferta |Adresa                              | Nume proprietar | Numar telefon | Adresa email
------------------------------------------------------------------------------------------------
0001       | -tested again and again AND FINAL- | Je Mapel        | -tested-      | i@hate.this 

( click on "view source" for a good view)
and I search in 2nd column, $caut = "Adresa".
How to resolve my problem, I searched on net but I can't find the solution to my code.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>