PDA

View Full Version : Auto Suggest



LazyM
09-10-2010, 09:30 PM
<?
session_start();

if (!(isset($_SESSION["real_name"])))
{
//echo "I'm not logged in";
header('Location: index.php');
}
else
{
echo "";
}


?>



<html>
<head>
<title>.: IM | Find :.</title></head>
<link REL="stylesheet" TYPE="text/css" HREF="main.css">

<script language=javascript src=Menus.js></script>

<body background="wallpaper.jpg">
<center>
<table border="0" cellspacing="0" cellpadding="0" align="center" width="95%" class="cat">

<TR>

<TD width="150" background="tdbg3.jpg" bgcolor="#222222" valign="top">
<?php include("leftmenu.php");?>
</TD>

<td width="100%" valign="top"> <br>


<?php
include "bb.php";
include "includes/db_connect.php";


$username=$_SESSION['real_name'];
$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);
?>
<form name="form1" method="post" action="">
<table width="80%" border="1" align="center" cellpadding="2" cellspacing="0" class="sub2" bordercolor=black>
<tr>
<td colspan="2" class="header"><center class=bold>
Search </center></td>
</tr>
<tr>
<td width="50%"><div align="center">Status:
<select style="border:1px solid black;" name="user_status" id="select">
<option value="Both">Both</option>
<option value="Alive">Alive</option>
<option value="Dead">Dead</option>
</select>
</div></td>
<td width="50%"><div align="center">Username:
<input name="user_username" style="border:1px solid black;" type="text" id="user_username3">
</div></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="user_button" type="submit" id="user_button6" value="Search"></td>
</tr>
<?php
$user_username=strip_tags($_POST['user_username']);
if (!ctype_alnum($user_username)==1) {
echo '';
} else {
if (strip_tags($_POST['user_username']) && strip_tags($_POST['user_status'])){
$user_status=strip_tags($_POST['user_status']);
$user_username=strip_tags($_POST['user_username']);
if ($user_status == "Both"){
$query="SELECT * FROM users WHERE username LIKE '%$user_username%'";
}elseif ($user_status == "Alive"){
$query="SELECT * FROM users WHERE username LIKE '%$user_username%' AND status='Alive'";
}elseif($user_status == "Dead"){
$query="SELECT * FROM users WHERE username LIKE '%$user_username%' AND status='Dead'";
}
$result=mysql_query($query);
$total=mysql_num_rows($result);
echo "<tr bgcolor=white><td colspan=2 align=center class=header>Players found</td></tr><tr><td class=header>Username</td><td class=header>Crew</td></tr>";
if ($total == "0"){ echo "<tr> <td colspan=2><center><b>No results found.</center></b></td></tr>"; }
while($a=mysql_fetch_object($result)){
if ($a->crew=="0"){ $crew="None"; }else{ $crew=$a->crew; }
echo "<tr>
<td><a href='viewprofile.php?viewuser=$a->username'>$a->username</a></td><td>$crew</td>
</tr>
";

}
}
}
?>
</table>
</form>


</td>



<TD width="150" valign="top">
<?php include("rightmenu.php");?>
</TD>

</TR>


</table>

</center>
</body>
</html>

How to make it auto suggestion?