$hostname = "localhost"; //?
$user = "root"; //?
$password = "root"; //??
$dbname = "car"; //??
$tblname = "data"; //??
if ($_POST['drive_name'] !='ทั้งหมด' and $_POST['department'] !='ทั้งหมด' and $_POST['car_number'] !='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where drive_name='$drive_name' and department='$department' and car_number='$car_number' and start_mile!='0' ";}
elseif ($_POST['drive_name'] !='ทั้งหมด' and $_POST['department'] ='ทั้งหมด' and $_POST['car_number'] ='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where drive_name='$drive_name' and start_mile!='0'";}
elseif ($_POST['drive_name'] ='ทั้งหมด' and $_POST['department'] !='ทั้งหมด' and $_POST['car_number'] ='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where department='$department' and start_mile!='0'";}
elseif ($_POST['drive_name'] ='ทั้งหมด' and $_POST['department'] ='ทั้งหมด' and $_POST['car_number'] !='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where car_number='$car_number' and start_mile!='0'";}
elseif ($_POST['drive_name'] !='ทั้งหมด' and $_POST['department'] !='ทั้งหมด' and $_POST['car_number'] ='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where department='$department' and drive_name='$drive_name' and start_mile!='0'";}
else
{ $sql ="SELECT * FROM data where year_round='$year_round'and start_mile!='0'
";}
คำสั่ง elseif อันสุดท้าย
elseif ($_POST['drive_name'] !='ทั้งหมด' and $_POST['department'] !='ทั้งหมด' and $_POST['car_number'] ='ทั้งหมด' )
{ $sql ="SELECT * FROM data
where department='$department' and drive_name='$drive_name' and start_mile!='0'";}