<? 
require_once('../include/configure.php');
require_once('../include/database.php');
require_once "../include/function.php"; 
require_once "../include/paginator.php";
require_once "../include/paginator_html.php";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../sddm.css" >
<title>Search</title>
<script src="../include/validation.js" type="text/javascript"></script>
<style type="text/css">
<!--
body {
	background-color: #CCCCCC;
}
-->
</style></head>

<body>
<br />
<form name="form" method="post" action="<?=$PHP_SELF ?>" >
<table border="0" cellpadding="1" width="100%" cellspacing="2" class="small">
  <tr>
    <td width="553" height="17" colspan="3" class="TextWhiteH1"><table width="100%" border="0" cellspacing="2" cellpadding="2">
        <tr>

          <td width="82%" height="25"><span class="TextH1">
            <select name="sType" id="sType">
                  <option value="Name">Name</option>
                  <option value="Email">Email</option>

            </select>
            <input name="sReferral" type="text" id="sReferral" value="<? echo $sReferral ?>" />
            </span>
        <tr>
          <td><input name="btnSearch" type="submit" class="btn" id="btnSearch" value="Search" />
            <input name="fld" type="hidden" id="fld" value="<? echo $fld ?>" /></td>
        </tr>
        
      </table></td>
  </tr>
  <tr>
    <td height="15" colspan="3">&nbsp;</td>
  </tr>
 
   <tr>
    <td height="15" colspan="3">
	<table border="0" cellpadding="1" width="100%" cellspacing="2" class="small">
  <tr>
    <td width="426" height="23" background="../images/tab-btns.gif" class="TextH1"><div align="center">Name</div></td>
    <td width="778" background="../images/tab-btns.gif" class="TextH1"><div align="center">Email </div></td>
    </tr>
  <?
if($btnSearch){ 
	$sql="select * from user ";
	if($sName){
		if($sType=="Name")$sql.=" where name like '%$sReferral%'";			
		else if($sType=="Email")$sql.=" where email like '%$sReferral%'";			
	
	}		
	$result=mysql_query($sql);
	$num_rows=mysql_num_rows($result);

	$pass="so=1&sReferral=$sReferral&sType=$sType&btnSearch=search";

    $a =& new Paginator_html($_GET['page'],$num_rows,$pass);	
	$a->set_Limit(15);
	$a->set_Links(10);  	
	$limit1 = $a->getRange1();  
	$limit2 = $a->getRange2();  
	$sql.=" order by name limit $limit1,$limit2 ";	
	$result=mysql_query($sql) or die(mysql_error());
	
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
	{
		$nm=$myrow["email"];		

		echo "<tr onClick=\"postEmail('$fld','$nm')\" class='TextWhiteH1' onMouseOver=\"this.bgColor = '#ff0000'\" onMouseOut =\"this.bgColor = '#333333'\" bgcolor='#333333'>"; 
		echo "<td height='20' align='center' >".$myrow["name"]."</td>";	  		
        echo "<td align='center'>".$myrow["email"]."</td>";	  						
		echo "</td>";	  								
		echo "</tr>";

	}

}
?>
  <tr>
    <td colspan="4" class="TextWhiteH1"><? echo "Total Record :[".$num_rows."] "; if($num_rows)$a->previousNext();?></td>
  </tr>
</table>

	
</td>
  </tr>
  
 
  <tr>
    <td colspan="3" class="Footer"><input name="Button" type="button" class="btn" value="Close Window" onclick="window.close();"/></td>
  </tr>
</table>
</form>
</body>
</html>
