Code:
<?php
include("config.php");
mysql_connect("Localhost" , "root" , "") or die(mysql_error());
mysql_select_db("imprimante");
if(isset($_POST["submit"])){
$search = $_POST["search"];
$sql = mysql_query("SELECT * FROM `inventar` i , `evidenta` e WHERE
(i.`ID_M` = '".$search."' and i.`ID_M` = e.`ID_M`) OR (i.`model` LIKE
'".$search."') OR (e.`data_intrare` = '".$search."') OR (e.`data_iesire` =
'".$search."') OR (i.`user` LIKE '".$search."' and i.`user` =
e.`user_iesire`) OR (i.`dept` LIKE '".$search."' and i.`dept` = e.`dept`) OR
(i.`tip` LIKE '".$search."') OR (i.`COD` like '".$search."') OR (i.`SERIA`
LIKE '".$search."') OR (i.`NR_INV` LIKE '".$search."')");
if(!$search){
echo "Nu ai cautat nimic...";
} else {
//WHILE PT RESULTURI
while($row = mysql_fetch_array($sql)){
echo '<br/> Model: '.$row['model'];
echo '<br/> ID Model: '.$row['ID_M'];
echo '<br/> Data Intrare: '.$row['data_intrare'];
echo '<br/> Data Iesire: '.$row['data_iesire'];
echo '<br/> User: '.$row['user'];
echo '<br/> User Iesire: '.$row['user_iesire'];
echo '<br/> Departament: '.$row['dept'];
echo '<br/> Tip Consumabil: '.$row['tip'];
echo '<br/> Cod Produs: '.$row['cod'];
echo '<br/> Seria: '.$row['SERIA'];
echo '<br/> Numar Inventar: '.$row['NR_INV'];
echo '<br/><br/>';
}
}
}?>
<html>
<head><title>Search Function</title></head>
<body>
<form action="search.php" method=POST>
<input type=text name="search" placeholder="Cauta"><br/><br/>
<input type=submit value="Cauta" name="submit"><br/><br/>
<button name="Index"><a href="../index.php">Index</a></button>
<button name="Evidenta"><a href="evidenta.php">Evidenta</a></button><br/>
</form>
</body>
</html>
why this query return always more results than I actually have in my DB and also return wrong results?
btw the two tables "inventar" and "evidenta" have a relationship through ID_M
thanks for the help :D