mysql - PHP : Can't create automatic query -


i want build search engine webpage. use code below. problem is, have build queries different strings , if system searches matching in strings, quote marks needed.

$sql = "select tit,vnev,knev,neme,megy,lcvar,apolg torzs left outer join vegzettseg on torzs.id = vegzettseg.id left outer join sztapasztalat on torzs.id = sztapasztalat.id left outer join szaktanfolyam on torzs.id = szaktanfolyam.id left outer join inform on torzs.id = inform.id "; ($i = 0;$i < count($searchcategs);$i++) {     $sql = $sql . $searchcategs[$i];     $sql = $sql . " = ";     $sql = $sql . $searchvals[$i];     $sql = $sql . " "; } 

an alternative version:

$sql = "select tit,vnev,knev,neme,megy,lcvar,apolg torzs left outer join vegzettseg on torzs.id = vegzettseg.id left outer join sztapasztalat on torzs.id = sztapasztalat.id left outer join szaktanfolyam on torzs.id = szaktanfolyam.id left outer join inform on torzs.id = inform.id "; ($i = 0;$i < count($searchcategs);$i++) {     $sql = $sql . $searchcategs[$i];     $sql = $sql . " = '";     $sql = $sql . $searchvals[$i];     $sql = $sql . "' "; } 

none of them seems work, got

select tit,vnev,knev,neme,megy,lcvar,apolg torzs left outer join vegzettseg on torzs.id = vegzettseg.id left outer join sztapasztalat on torzs.id = sztapasztalat.id left outer join szaktanfolyam on torzs.id = szaktanfolyam.id left outer join inform on torzs.id = inform.id

for query though searchcateg , searchval arrays existing , not empty.


Comments