I use a html form with 6 criterias, using $_POST lat's convert criterias in variables like here:
Case 1 - All criterias are default
$core = null; $mhz = null; $ram = null; $cam = null; $mAh = null $screen = null
The correct sql query is this :
$sql = "SELECT * FROM $tbl_name ORDER BY performanta_cpu_core DESC, performanta_cpu DESC, performanta_rami DESC LIMIT $start, $limit";
Case 2 - Only one criteria is set
$core = null; $mhz = "performanta_cpu=1400"; $ram = null; $cam = null; $mAh = null $screen = null
The corect query is this :
$sql = "SELECT * FROM $tbl_name WHERE $mhzz ORDER BY performanta_cpu_core DESC, performanta_cpu DESC, performanta_rami DESC LIMIT $start, $limit";
Case 3 - Here is the problem All or more than one criterias ore setted:
$core = 2; $mhz = "performanta_cpu=1400"; $ram = "performanta_rami=1024"; $cam = "camera_spate=3.2"; $mAh = "baterie_mAh=2250"; $screen = "densitate=441";
I understand that i have need to make "WHERE" to be dinamic and visible just when any variable is set and also I have need an "AND" also dinamically like:
$sql = "SELECT * FROM $tbl_name WHERE $core AND $mhzz ORDER BY performanta_cpu_core DESC, performanta_cpu DESC, performanta_rami DESC LIMIT $start, $limit";
I am stressed for a week with this and i cant advance without help...
Thanks in advance
WHERE $mhzzyou dont set a value to comparison. Please read the following text for better understanding dynamically query creating. link