can't get it working, please help me as I modify the code from other souces.

Thank you.


search.html
Code HTML4Strict:
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 
<title>Search Online</title>
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 
 
 
<style type="text/css">
<!--
.style7 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
.style10 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; }
.style11 {font-size: 11px}
.style4 {font-size: 12px; font-family: Arial, Helvetica, sans-serif; font-weight:100; }
.style5 {	color: #FFFFFF;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
	font-weight: bold;
}
-->
</style>
 
<link href="../../style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
 
<body>
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
 
  <tr>
    <td><hr size="1" noshade></td>
  </tr>
  <tr>
    <td>      <table width="775" border="0" align="center" cellpadding="0" cellspacing="0">
 
        <tr>
          <td><form name="form1" method="post" action="search_page2.php">
            <table width="550" border="0" align="center" cellpadding="1" cellspacing="2">
              <tr>
                <td class="style10">By Username</td>
                <td><input name="username" type="text" id="username"></td>
              </tr>
              <tr>
                <td width="205"><span class="style10">By Name </span></td>
              <td width="335"><input name="name" type="text" id="name"></td>
            </tr>
              <tr>
                <td class="style10"> By Reference #</td>
                <td><input name="reference" type="text" id="reference"></td>
              </tr>
              <tr>
                <td><span class="style10">Maid Types</span></td>
              <td><span class="style7">
                <span class="style4">
                  <select name="types" id="types">
                    <option value="">-- Select Maid Types -- </option>
                    <option value="new">New</option>
                    <option value="old">Old</option>
                    <option value="transfer">Transfer</option>
                    </select>
                  </span>            </span></td>
            </tr>
              <tr>
                <td><span class="style10">By Marital Status </span></td>
              <td><span class="style7">
                <select name="marital_status" id="marital_status">
                  <option value="">---Select Marital Status---</option>
                  <option value="Single">Single</option>
                  <option value="Married">Married</option>
                  <option value="Separated">Separated</option>
                  <option value="Widowed">Widowed</option>
                  <option value="Divorced">Divorced</option>
                  <option value="Others">Others</option>
                  </select>
                </span></td>
            </tr>
              <tr>
                <td class="style10">By Age</td>
              <td><span class="style4">
                <select name="age" id="age">
                  <option value="18">18</option>
                  <option value="19">19</option>
                  <option value="20">20</option>
                  <option value="21">21</option>
                  <option value="22">22</option>
                  <option value="23">23</option>
                  <option value="24">24</option>
                  <option value="25">25</option>
                  <option value="26">26</option>
                  <option value="27">27</option>
                  <option value="28">28</option>
                  <option value="29">29</option>
                  <option value="30">30</option>
                  <option value="31">31</option>
                  <option value="32">32</option>
                  <option value="33">33</option>
                  <option value="34">34</option>
                  <option value="35">35</option>
                  <option value="36">36</option>
                  <option value="37">37</option>
                  <option value="38">38</option>
                  <option value="39">39</option>
                  <option value="40">40</option>
                  <option value="41">41</option>
                  <option value="42">42</option>
                  <option value="43">43</option>
                  <option value="44">44</option>
                  <option value="45">45</option>
                  <option value="46">46</option>
                  <option value="47">47</option>
                  <option value="48">48</option>
                  <option value="49">49</option>
                  <option value="50">50</option>
                                </select>
              </span></td>
            </tr>
              <tr>
                <td class="style10">By Religion </td>
              <td><span class="style4">
                <select name="religion" id="religion">
                  <option value="">Select Religion</option>
                  <option value="Cathoic">Cathoic</option>
                  <option value="Christians">Christians</option>
                  <option value="Muslims">Muslims</option>
                  <option value="Buddhists">Buddhists</option>
                  <option value="Sikhs">Sikhs</option>
                  <option value="Jains">Jains</option>
                  <option value="Hindus">Hindus</option>
                  <option value="Others">Others</option>
                  </select>
                </span></td>
            </tr>
              <tr>
                <td><span class="style10">By Nationality</span></td>
              <td><select name="nationality" id="nationality">
                <option value="">Select Maid Nationality</option>
                <option value="Philipino">Philipino</option>
                <option value="Chinese">Chinese</option>
                </select></td>
            </tr>
              <tr>
                <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
              <tr>
                <td><span class="style10"><strong>Criteria</strong></span></td>
              <td><span class="style7">
                <select name="o" id="o">
                  <option value="AND">AND</option>
                  <option value="OR">OR</option>
                  </select>
                </span></td>
            </tr>
              <tr>
                <td><span class="style11"></span></td>
              <td>&nbsp;</td>
            </tr>
              <tr>
                <td colspan="2"><input name="Submit" type="submit" value="          Search Maids           "></td>
            </tr>
              </table>
      </form></td>
    </tr>
      </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>


search_page2.php
PHP Code:
<?
include("conn.php");
$username=$_POST["username"];
$name=$_POST["name"];
$reference=$_POST["reference"];
$types=$_POST["types"];
$marital_status=$_POST["marital_status"];
$age=$_POST["age"];
$religion=$_POST["religion"];
$nationality=$_POST["nationality"];




$o=$_POST["o"];
                 
$rest="";
                 
$text="Search Keywords : ";
                 
                 
                     if(
$username!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.=" where username='$username' ";
                                
$text.="Username = $username";
                            }
                            else
                            {
                            
$rest.=$o username='$username' ";
                            
$text.=", Username = $username";
                            }
                     }
                     
                     if(
$name!="")
                     {
                         if(
$rest=="")
                            {
                         
$rest.=" where fname like '$name%' or lname like '$name%' ";
                         
$text.="Name like $name ";
                         }
                         else {
                             
$rest.="$o where fname like '$name%' or lname like '$name%' ";
                             
$text.="Name like $name ";
                         }
                     }
                     if(
$reference!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.=" where reference='$reference' ";
                                
$text.="Reference = $reference";
                            }
                            else
                            {
                            
$rest.=$o reference='$reference' ";
                            
$text.=", Reference = $reference";
                            }
                     }
                     
                     if(
$types!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.=" where types='$types' ";
                                
$text.="Types = $types";
                            }
                            else
                            {
                            
$rest.=$o types='$types' ";
                            
$text.=", Types = $types";
                            }
                     }
                     
                     if(
$marital_status!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.="where marital_status='$marital_status' ";
                                
$text.="Marital Staus = $marital_status";
                            }
                            else
                            {
                            
$rest.=$o marital_status='$marital_status' ";
                            
$text.=", Marital Staus = $marital_status";
                            }
                     }
                     
                      if(
$age!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.="where age = '$age' ";
                                
$text.="Age = $age ";
                            }
                            else
                            {
                            
$rest.=$o  age = '$age' ";
                            
$text.=", Age = $age ";
                            }
                     }
                     
                     if(
$religion!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.="where religion = '$religion' ";
                                
$text.="Religion = $religion";
                            }
                            else
                            {
                            
$rest.=$o  religion = '$religion' ";
                            
$text.=", Religion = $religion";
                            }
                     }
                     if(
$nationality!="")
                     {
                         if(
$rest=="")
                            {
                                
$rest.="where nationality = '$nationality' ";
                                
$text.="Nationality = $nationality";
                            }
                            else
                            {
                            
$rest.=$o  nationality = '$nationality' ";
                            
$text.=", Nationality = $nationality";
                            }
                     }
                     
                     
                    if(
$rest!="")
                    {
                    
$rest=$rest;
                    }
                    else
                    {
                        
//die("Enter Search Parameter<br><br><br><br><br><br><br><br><br><br><br>");
                    
}

$sql="select $users.* from $users order by username"
$result=mysql_query($sql,$connection) or die(mysql_error());            
$num=mysql_num_rows($result);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>Great Hand International Limmited - Maid Details</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<link href="../../style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../../script.js"> </script>
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>

<body>
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  
  <tr>
    <td><hr size="1" noshade></td>
  </tr>
  <tr>
    <td>
      <table width="750" border="0" align="center" cellpadding="2" cellspacing="2">
        <tr>
          <td align="left">
<?
echo "<div align=right>$text</div>";
echo 
"<table width=700 border=0 cellpadding=0 cellspacing=0 align=center>\n
<tr>\n
    <td> Total No of Records Found: 
$num &nbsp; \n
    <td> &nbsp;\n
    
</tr>\n
<tr> \n"
;
$counter=0;
while(
$row=mysql_fetch_array($result))
{
    
$id=$row['id'];
    
$username=$row['username'];    
    
$name=$row['fname']."  ".$row['lname'];
    
$reference=$row['reference'];
    
$types=$row['types'];    
    
$pic=$row['pic'];
    
    
$depsql="select * from $users where id='$id'";
    
//echo $depsql;
    
$rDep=mysql_query($depsql,$connection) or die(mysql_error());
    while(
$r=mysql_fetch_array($rDep)) {
        
$username=$r['username'];
    }
    
    if(
$counter>=0) {
    echo 
"<td valign=top>\n
    <table width=340 border=0 align=left class=allborder> \n
    <tr> \n
        <td width=120> Name:  <td>
$name\n
    </tr>\n
        <tr> \n
        <td> Department:  <td> 
$depname\n
    </tr>\n
        <tr> \n
        <td> Gender:  <td> 
$gender\n
    </tr>\n
    
        <tr> \n
        <td> Date Of Birth:  <td> 
$dob\n
    </tr>\n
        
    </tr>\n
        <tr> \n
        <td colspan=2 class=topBorder> <a href=viewdetail.php?sn=
$sn>View Detail Info</a>\n
    </tr>\n
    </table>\n</td>\n
     "
;
     
$counter++;
     } 
     if(
$counter==2) {
         echo 
"</tr>\n<tr>\n<td colspn=2>&nbsp; \n</tr>\n<tr>\n";
        
$counter=0;
     }
}
echo 
"</table>\n";
?></td>
        </tr>
    </table></td>
  </tr>
</table>
</body>
</html>