How do i make this more dynamic

Hello this code below works but i would like to make it more dynamic
so that i dont need to add line’s to the code to build a good query for searching the data base.

i get the data from _GET and then check if there is data or not and fill the query.
the problem is that i need to check it like below or the query just fails if there is a , or something wrong.

[php]// komma b check
if (!empty($cc)&&!empty($bb)){$kommab = ", ";}
if (!empty($dd)&&!empty($bb)){$kommab = ", ";}
if (!empty($ee)&&!empty($bb)){$kommab = ", ";}
if (!empty($ff)&&!empty($bb)){$kommab = ", ";}
// komma c check
if (!empty($dd)&&!empty($cc)){$kommac = ", ";}
if (!empty($ee)&&!empty($cc)){$kommac = ", ";}
if (!empty($ff)&&!empty($cc)){$kommac = ", ";}
// komma d check
if (!empty($ee)&&!empty($dd)){$kommad = ", ";}
if (!empty($ff)&&!empty($dd)){$kommad = ", ";}
// komma e check
if (!empty($ff)&&!empty($ee)){$kommae = ", ";}
// komma f check
if (!empty($gg)&&!empty($ff)){$kommaf = ", ";}

// Here i fill the query in $col then $col is used in the query to search in certain table collums
$col = $bb. $kommab . $cc . $kommac . $dd . $kommad . $ee . $kommae . $ff . $kommaf ;
[/php]

code from _GET

[php]
$a=$_GET[“a”]; // $var the search text
$b=$_GET[“b”]; // naam1 table collum
$c=$_GET[“c”]; // postcode1 table collum
$d=$_GET[“d”]; // plaats1 table collum
$e=$_GET[“e”]; // land1 table collum
$f=$_GET[“f”]; // adres1 table collum

if (!empty($b)){ $bb = “naam1” ;}
if (!empty($c)){ $cc = “postcode1” ;}
if (!empty($d)){ $dd = “plaats1” ;}
if (!empty($e)){ $ee = “land1” ;}
if (!empty($f)){ $ff = “adres1” ;}[/php]

code from the query any tips on this query are welcome also:

[php]$query_adressen = "
SELECT ,
MATCH( $col ) AGAINST(’$var
’ IN BOOLEAN MODE) AS score
FROM adressen
WHERE active = 1
AND MATCH( $col ) AGAINST(’$var*’ IN BOOLEAN MODE)
ORDER BY score DESC
"; }[/php]

i like to impove this code and i hope you can help

Thx

Kees

Sponsor our Newsletter | Privacy Policy | Terms of Service