<?php
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
$objDB = mysql_select_db("testdb");
$strSQL = "select * from tb_name where year_name='".$_post['ddlyear']."' or
('".$_post['ddlyear']."' = '' and year_name = (
select top 1 year_name from tb_year where year_status = 'enable' order by year_name desc
))";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>