ob_start();
session_start();
$HOME = “/home/xuanaucom”;
ini_set(
‘include_path’,
ini_get( ‘include_path’ ) . PATH_SEPARATOR . “$HOME/pear/php”
);
?>
// Load the HTML_QuickForm module
require_once ‘DB.php’;
require ‘HTML/QuickForm.php’;
// Instantiate a new form
$form = new HTML_QuickForm(’form_regx’, ‘get’, ‘/search’);
//database
PEAR::setErrorHandling(PEAR_ERROR_DIE);
//$dsn = “mysql://xuan:xuanau@abc.guidesinchina.cn/guidesincn1″;
$dsn = “mysql://johnwb:johnwb@ts.teachingsupply.co.uk/teachsupply”;
$gic = DB::connect($dsn);
$querynat = ‘SELECT distinct(nationality) FROM TeacherRegister ORDER BY nationality ASC’;
// **************** Add nationality from DB *******************
$sheng =& $form->addElement(’select’, ‘nationality’,
‘Nationality: ‘, // labels
null,”single”// custom layout
);
$sheng->load($gic, $querynat, ‘nationality’, ‘nationality’);
$qual_s =& $form->createElement(’select’,'qual’,'Qualifications: ‘);
$qual_options = array (”All”=>”All”, “High School Grad”=>”High School Grad”,”Bachelors” => “Bachelors”, “Honours” => “Honours”, “Masters” => “Masters”, “PhD” => “PhD”);
$qual_s->loadArray($qual_options,’All’);
$form->addElement($qual_s);
$yrs_ex =& $form->createElement(’select’,'experience’,'Years of experience: ‘);
$yrs_ex->setsize(1);
$yrs_ex_opts = array(’All’ => ‘All’, ‘0-2′ => ‘0-2′, ‘2-4′ => ‘2-4′,’4-6′ => ‘4-6′, ‘6-8′ => ‘6-8′, ‘8-10′ => ‘8-10′, ‘10+’ => ‘10+’);
$yrs_ex->loadArray($yrs_ex_opts);
$form->addElement($yrs_ex);
// Add text boxes
$form->addElement(’text’,'email’,'Email:’,’size=”30″ maxlength=”128″‘);
$form->addElement(’text’,’subject’,'Name:’,’size=”30″ maxlength=”128″‘);
$form->addElement(’select’, ‘from’, ‘How did you hear about us?’, array (”Direct Mailing” => “Direct Mailing”, “Google Search” => “Google Search”,”Facebook advertising” => “Facebook advertising”, “Shanghai Expat”=> “Shanghai Expat”,”Serious Teachers” => “Serious Teachers”, “TEFL.Net” => “TEFL.Net”, “Word of Mouth” => “Word of Mouth”, “Other” => “Other”));
// Add a submit button
//$form->addElement(’image’,'button’,'/images/search-button.gif’);
$form->addElement(’submit’,'button’,'Submit’);
if ($form->validate()) {
?>
process(’reg_pass’);
} else {
?>
?>
}
function reg_pass($v) {
$PageSize = 10;
$StartRow = 0;
if(empty($_GET['PageNo'])){
if($StartRow == 0){
$PageNo = $StartRow + 1;
}
}else{
$PageNo = $_GET['PageNo'];
$StartRow = ($PageNo – 1) * $PageSize;
}
if($PageNo % $PageSize == 0){
$CounterStart = $PageNo – ($PageSize – 1);
}else{
$CounterStart = $PageNo – ($PageNo % $PageSize) + 1;
}
$CounterEnd = $CounterStart + ($PageSize – 1);
/***************************************************/
$nationality=$_GET['nationality'];
$qualification=$_GET['qual'];
$yrs_exp=$_GET['experience'];
/*** adding in Gender selection **/
$guide_id=$_GET['guide_id'];
if($_GET['gender']==”"){
$gender=”All”;
} else{
$gender=$_GET['gender'];
}
if($qualification==”All” && $yrs_exp ==”All”){
$query_total = mysql_query(”SELECT * FROM TeacherRegister WHERE nationality=’”.$nationality.”‘ “);
$query = “SELECT * FROM TeacherRegister WHERE nationality=’”.$nationality.”‘ ORDER BY uimage DESC, id LIMIT $StartRow,$PageSize”;
} elseif($qualification==”All”){
$query_total = mysql_query(”SELECT * FROM TeacherRegister WHERE experience =’”.$yrs_exp.”‘ AND nationality=’”.$nationality.”‘ “);
$query = “SELECT * FROM TeacherRegister WHERE experience =’”.$yrs_exp.”‘ AND nationality=’”.$nationality.”‘ ORDER BY uimage DESC, id LIMIT $StartRow,$PageSize”;
} elseif($yrs_exp==”All”){
$query_total = mysql_query(”SELECT * FROM TeacherRegister WHERE highest_qual =’”.$qualification.”‘ AND nationality=’”.$nationality.”‘ “);
$query = “SELECT * FROM TeacherRegister WHERE highest_qual =’”.$qualification.”‘ AND nationality=’”.$nationality.”‘ ORDER BY uimage DESC, id LIMIT $StartRow,$PageSize”;
} else {
//Add May31 ZH to include services offered like function
$query_total = mysql_query(”SELECT * FROM TeacherRegister WHERE experience =’”.$yrs_exp.”‘ AND highest_qual =’”.$qualification.”‘ AND nationality =’”.$nationality.”‘”);
$query = “SELECT * FROM TeacherRegister WHERE experience =’”.$yrs_exp.”‘ AND highest_qual =’”.$qualification.”‘ AND nationality=’”.$nationality.”‘ ORDER BY uimage DESC,id LIMIT $StartRow,$PageSize”;
}
//echo $query;
/******** finish adding in Gender selection *******/
$result = mysql_query($query);
/***************************************************/
$RecordCount = mysql_num_rows($query_total);
$MaxPage = $RecordCount % $PageSize;
if($RecordCount % $PageSize == 0){
$MaxPage = $RecordCount / $PageSize;
}else{
$MaxPage = ceil($RecordCount / $PageSize);
}
/***************************************************/
?>
We have found match(es).
while ($row_Recordset1 = mysql_fetch_assoc($result)) {
echo ”
“;
}
/**********************************************/
$nationality = urlencode($nationality);
$qualification = urlencode($qualification);
$yrs_exp = urlencode($yrs_exp);
echo ““;
if($PageNo != 1){
$PrevStart = $PageNo – 1;
print “First : “;
print “Previous “;
}
print ” [ ";
$c = 0;
for($c=$CounterStart;$c<=$CounterEnd;$c++){
if($c < $MaxPage){
if($c == $PageNo){
if($c % $PageSize == 0){
print " $c ";
}else{
print " $c - ";
}
}elseif($c % $PageSize == 0){
echo "$c ";
}else{
echo "$c - ";
}//END IF
}else{
if($PageNo == $MaxPage){
print " $c ";
break;
}else{
echo "$c ";
break;
}//END IF
}//END IF
}//NEXT
echo "] “;
if($PageNo < $MaxPage){
$NextPage = $PageNo + 1;
echo “Next“;
}
if($PageNo < $MaxPage){
$LastRec = $RecordCount % $PageSize;
if($LastRec == 0){
$LastStartRecord = $RecordCount – $PageSize;
}
else{
$LastStartRecord = $RecordCount – $LastRec;
}
print ” : “;
echo “Last“;
}
echo ““;
/**********************************************/
}
?>