search result via multiple/optional dropdown list
Posted: Thu May 10, 2012 4:06 pm
below is my search form, in which i want to search any one or multiple criterias via dropdown lists/date

My problem is if any field is left not selected it will give error i.e. not pass any value in the query or pass "" that is null,
what to do if i want to select all values in the list if not selected
Query is
SELECT t1.log_id, t1.student_name, t4.course_detail, t5.branch_detail, t6.source_details, t7.ref_name
FROM register_logged t1
left join course_master t4 on t4.course_id = t1.course_id
left join branch_mast t5 on t5.branch_id = t1.branch_id
left join source_master t6 on t6.source_id = t1.source_id
left join refrences_mast t7 on t7.ref_id = t1.ref_id
where t1.course_id = '$course_id' and
t1.branch_id = $branch_id and
t1.source_id = '$source_id' and
t1.ref_id = '$ref_id' and
t1.status in ('$status') and
t1.date between '$date1' & '$date2'
confused what to do???

My problem is if any field is left not selected it will give error i.e. not pass any value in the query or pass "" that is null,
what to do if i want to select all values in the list if not selected
Query is
SELECT t1.log_id, t1.student_name, t4.course_detail, t5.branch_detail, t6.source_details, t7.ref_name
FROM register_logged t1
left join course_master t4 on t4.course_id = t1.course_id
left join branch_mast t5 on t5.branch_id = t1.branch_id
left join source_master t6 on t6.source_id = t1.source_id
left join refrences_mast t7 on t7.ref_id = t1.ref_id
where t1.course_id = '$course_id' and
t1.branch_id = $branch_id and
t1.source_id = '$source_id' and
t1.ref_id = '$ref_id' and
t1.status in ('$status') and
t1.date between '$date1' & '$date2'
confused what to do???