if(!$P) {
$P = 1; // start on page 1.
} else {
if(strspn($P,"0123456789")<>strlen($P)) { // make sure it's a number.
$P = 1;
} else {
if($P < 1) {
$P = 1;
}
}
}
$sealDateIssue = $_REQUEST['sealDateIssue'];
$sealDateExpire = $_REQUEST['sealDateExpire'];
if(!strcmp($sealDateIssue,"1969-12-31")) {
$sealDateIssue = "";
}
if(!strcmp($sealDateExpire,"1969-12-31")) {
$sealDateExpire = "";
}
if(strlen($sealDateIssue) > 1 && strlen($sealDateExpire) > 1) { // both start date and end date
if(!$_REQUEST['company'] && !$_REQUEST['country']) { // none
$query = "select * from factoryInfo where compliancsealDateExpire>= '$sealDateIssue' AND compliancsealDateExpire<= '$sealDateExpire' order by $SORT asc";
} else
if($_REQUEST['company'] && $_REQUEST['country']) { // all
$query = "select * From factoryInfo where factoryName like '%".$_REQUEST['company']."%' and country like ".
"'%".$_REQUEST['country']."%' order by $SORT asc";
} else
if($_REQUEST['company']) { // only company
$query = "select * From factoryInfo where factoryName like '%".$_REQUEST['company']."%' order by $SORT asc";
} else { // only country
$query = "select * From factoryInfo where country like '%".$_REQUEST['country']."%' order by $SORT asc";
}
} else
if(strlen($sealDateIssue) > 1) { // only start date
if(!$_REQUEST['company'] && !$_REQUEST['country']) { // none
$query = "select * from factoryInfo where compliancsealDateExpire>= '$sealDateIssue' order by $SORT asc";
} else
if($_REQUEST['company'] && $_REQUEST['country']) { // all
$query = "select * From factoryInfo where factoryName like '%".$_REQUEST['company']."%' and country like ".
"'%".$_REQUEST['country']."%' AND compliancsealDateExpire>= '$sealDateIssue' order by $SORT asc";
} else
if($_REQUEST['company']) { // only company
$query = "select * From factoryInfo where factoryName like '%".$_REQUEST['company']."%' AND compliancsealDateExpire>= '$sealDateIssue' order by $SORT asc";
} else { // only country
$query = "select * From factoryInfo where country like '%".$_REQUEST['country']."%' AND compliancsealDateExpire>= '$sealDateIssue' order by $SORT asc";
}
} else { // no date search
if(!$_REQUEST['company'] && !$_REQUEST['country']) { // none
$query = "select * from factoryInfo order by $SORT asc";
} else
if($_REQUEST['company'] && $_REQUEST['country']) { // all
$query = "select * From factoryInfo where factoryName like '%".$_REQUEST['company']."%' and country like ".
"'%".$_REQUEST['country']."%' order by $SORT asc";
} else
if($_REQUEST['company']) { // only company
$query = "select * From factoryInfo where factoryName like '%".$_REQUEST['company']."%' order by $SORT asc";
} else { // only country
$query = "select * From factoryInfo where country like '%".$_REQUEST['country']."%' order by $SORT asc";
}
}