if isset _POST ok searchterm _POST searchterm searchtype _POST searcht

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
<?
if (isset($_POST["ok"]))
{
$searchterm = $_POST["searchterm"];
$searchtype = $_POST["searchtype"];
trim($searchterm);
if (!$searchtype || !$searchterm)
{
header("Location: search.php");
exit;
}
$searchterm = addslashes ($searchterm) ;
include("db.inc");
mysql_select_db( "book") ;
$query = "select * from `bookb` where " .$searchtype. " like \"%" .$searchterm. "%\" " ;
$result = mysql_query($query) ;
$num_results = mysql_num_rows ($result) ;
$search_results = "";
$search_results .="<table cellpadding=0 cellspacing=0 border=0 width=100%>";
if ($num_results)
{
$search_results .= "<TR>";
$search_results .= "<TD valign='top' class='size'>Avtori" ;
$search_results .= "<TD class='size'>Nomi ";
$search_results .= "<TD class='size'>Yo'nalishi " ;
$search_results .= "<TD class='size'>O'qish ";
$search_results .= "</TR>";
//list($id,$upload,$author,$name,$direction,$publish,$cityname,$booktype)=mysql_fetch_row($result);
for ($i=1; $i <=$num_results; $i++)
{
$row = mysql_fetch_array($result);
$search_results .= "<TR>";
$search_results .= "<TD class='size1'>";
$search_results .= htmlspecialchars (stripslashes($row["author"]))."</td>";
$search_results .= "<TD class='size1'>";
$search_results .= htmlspecialchars (stripslashes($row["name"] ))."</td>";
$search_results .= "<TD class='size1'>";
$search_results .= htmlspecialchars (stripslashes($row["direction"] ))."</td>";
$search_results .= "<TD class='size1'>";
$search_results .="<a href=$upload?id=$id>Read</a>";
$search_results .= "</tr>";
}
$search_results .="</table>";
}
}
else
$search_results = "";
?>
<html>
<head>
<link href=once.css rel=stylesheet>
<title>Book Catalog Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
b{font-color:blue; font-size:14px;}
</style>
</head>
<body background="fon.jpg">
<form action='search.php' method="POST">
<table width=100% height=100% class=chet1>
<tr valign="top"><td valign="top">
<td>
<TABLE border='0' cellspacing='1' cellpadding='3' width='100%' height=25%>
<tr><td height="200"><img src="banner.gif" width="100%" height="100%">
</td>
</tr>
</table>
<TABLE border='0' cellspacing='1' cellpadding='3' width='100%' >
<tr>
<td align="left">
Terminni kiriting:
<input name="searchterm" type="text" size="40">
<input type="submit" name="ok" value="Search"'>
</td>
</tr>
<tr>
<td align="left">
Qidiruv turini tanlang:
<input type="radio" name="searchtype" value="author" checked><b> Avtor</b>
<input type="radio" name="searchtype" value="name"><b>Nom</b>
<input type="radio" name="searchtype" value="direction"><b>Yo'nalish</b>
<input type="radio" name="searchtype" value="bbk"><b>BBK</b>
<hr style="color:lightblue;" width=100%>
</td>
<?=$search_results?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>