📄 result.php
字号:
<html>
<head>
<title>InterShop-Search result</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../style.css">
<script language=javascript>
function view(id)
{
var arg= "width=420,height=300,resizable=no,scrollbars=yes,status=0,top=0,left=0";
window.open ("itemdetail.php?ItemID="+ id ,"a",arg);
}
</script>
<script language=javascript>
//----BEGIN implement for paging----------//s
function GotoPage(iPage) {
document.form1.curPg.value=iPage
document.form1.submit()
}
</script>
</head>
<body >
<form action="result.php" method=post name=form1>
<table width="500" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td valign="top" >
<?php
require("../dbcon.inc");
$wh="";
$msg="";
$timkiem=$HTTP_POST_VARS{"txtkeyword"};
$txtkeyword=$timkiem;
$timkiem=str_replace ("'", "''", $timkiem);
if($timkiem!=""){
$wh.=" and ItemName like '%".$timkiem."%' or Description like '%".$timkiem."%'";
$msg.=$timkiem;
}
$timkiem=$HTTP_POST_VARS{"txtname"};
$txtname=$timkiem;
$timkiem=str_replace ("'", "''", $timkiem);
if($timkiem!=""){
$wh.=" or ItemID like '%".$timkiem."%'";
$msg.=",".$timkiem;
}
$timkiem=$HTTP_POST_VARS{"txtISBN"};
$txtisbn=$timkiem;
$timkiem=str_replace ("'", "''", $timkiem);
if($timkiem!=""){
$wh.=" or ItemID like '%".$timkiem."%'";
$msg.=",".$timkiem;
}
#Tim theo Author
$timkiem=$HTTP_POST_VARS{"txtauthor"};
$txtauthor=$timkiem;
$timkiem=str_replace ("'", "''", $timkiem);
if($timkiem!=""){
$wh.=" or AuthName like '%".$timkiem."%'";
$msg.=",".$timkiem;
}
if($wh=="")
$msg= "<font face='Arial'>Tất cả</font>";
$sotrang=$HTTP_POST_VARS{"pages"};
$record=$HTTP_POST_VARS{"records"};
$wh=" and (activate=1 ".$wh.")";
$sortby=" order by ItemName";
$totalRows = 0;
$paging="";
$stSQL ="select ItemID,ItemName,Description, AuthName,Pages,Price,PublishYear,edition, Size from tblBooks, tblauthors where tblBooks.AuthID= tblauthors.AuthID ".$wh;
$stSQL.=$sortby;
$result = mysql_query($stSQL, $link);
$totalRows=mysql_num_rows($result);
$maxRows = $record;
$maxPages = $sotrang;
if($totalRows%$maxRows==0)
$totalPages = (int)($totalRows/$maxRows);
else
$totalPages = (int)($totalRows/$maxRows+1);
$curPage =1;
if($HTTP_POST_VARS{"curPg"}=="")
$curPage =1;
else
$curPage = $HTTP_POST_VARS{"curPg"};
$curRow = ($curPage-1)*$maxRows+1;
$paging ="Current Page : <font color=red>".$curPage."</font> "."Total pages : <FONT color=red>".$totalPages."</FONT><br> ";
if($totalRows>$maxRows)
{
$start=1;
$end=1;
$paging1 ="";
for($i=1;$i<=$totalPages;$i++)
{ if(($i>((int)(($curPage-1)/$maxPages))* $maxPages) && ($i<=((int)(($curPage-1)/$maxPages+1))* $maxPages))
{
if($start==1) $start=$i;
if($i==$curPage)
$paging1 .= $i." ";
else
$paging1 .= "<a href='javascript:GotoPage(".$i.")'>".$i."</a> ";
$end=$i;
}
}
$paging.= "Go to page : " ;
if($curPage>$maxPages)
$paging .="<a href='javascript:GotoPage(".($start-1).")'>Previous</a> ";
$paging.=$paging1;
if(((($curPage-1)/$maxPages+1)*$maxPages) < $totalPages)
$paging .= "<a href='javascript:GotoPage(".($end+1).")'>Next</a> ";
}
?>
<table border="0" width="100%"><tr><td align=left><b>Search by:
<font color=red><?=$msg?></font></b></td>
<td align=right><b><a href="search.php">Back to Search</a>
<a href="viewcart.php">View Cart</a></b>
</td>
</tr>
<tr><td align=left><font face="Arial" color="#0066cc">Tổng
số Items tìm thấy <b><font color="#ff0000">
<?=$totalRows?>
</font></b></font></td>
<td align=right> <?=$paging?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="middle" valign="top" >
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="center">
<td width="5%" height="14" align="middle"><font face="Arial" color="#ff6600">No</font></td>
<td width="29%" height="14"><font face="Arial" color="#ff6600">Item Name</font></td>
<td width="10%" height="14"><font face="Arial" color="#ff6600">
Price</font></td>
<td width="12%" height="14"><font face="Arial" color="#ff6600">Size</font></td>
<td width="10%" height="14"><font face="Arial" color="#ff6600">Pages</font></td>
<td width="10%" height="14" align="left"><font face="Arial" color="#ff6600">Year</font></td>
<td width="25%" height="14">
<div><font face="Arial" color="#ff6600">Author Name</font></div>
</td>
</tr>
<tr valign="top">
<td colspan="7" align="middle">
<hr noshade size="1">
</td>
</tr>
<?php
if($totalRows>0)
{
$i=0;
$low=$curRow;
$curRow=1;
while (($row = mysql_fetch_array ($result))&&($curRow<=$totalRows) && ($curRow <= $curPage*$maxRows))
{
$curRow++;
if($curRow>$low)
{
$itemid=$row["ItemID"];
$itemname=$row["ItemName"];
$description=$row["Description"];
$authname=$row["AuthName"];
$pages=$row["Pages"];
$price=$row["Price"];
$publishyear=$row["PublishYear"];
$size=$row["Size"];
$i+=1;
?>
<tr valign="top">
<td align="middle"><font face="Arial" color="#0066cc">
<?=$curRow-1?>
</font> </td>
<td ><font face="Arial" color="#0066cc"><A href="javascript:view('<?=$itemid?>');">
<?=$itemname?>
</A></font></td>
<td ><font face="Arial" color="#0066cc">
<?=$price?>
</font></td>
<td ><font face="Arial" color="#0066cc">
<?=$size?>
</font></td>
<td><font face="Arial" color="#0066cc">
<?=$pages?>
</font></td>
<td ><FONT face="Arial"
color=#0066cc>
<?=$publishyear?>
</FONT></td>
<td >
<div><font face="Arial" color="#0066cc">
<?=$authname?>
</font></div>
</td>
</tr>
<?php
}}
}else{
?>
<tr valign="top">
<td width="5%" align="middle"> </td>
<td colspan=6 valign=center align="center"><b><font face="Arial" color="#FF0000">Oop!
Items not found! please select other criteria.</font></b></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<tr>
<td colspan=6>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan=2>
<hr noshade size="1">
</td>
</tr>
<tr>
<td align="left" valign="center"><font face="Arial" color="#0066cc">Tổng
số Items tìm thấy <b><font color="#ff0000">
<?=$totalRows?>
</font></b></font></td><td align=right><font face="Arial" color="#0066cc">
<?=$paging?>
</font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="96%" colspan=6><font face="Arial" color="#FF6600">
<input type=hidden name=pages value="<?=$pages?>">
<input type=hidden name=records value="<?=$records?>">
<input type=hidden name="txtkeyword" value="<?=$txtkeyword?>">
<input type=hidden name="txtISBN" value="<?=$txtISBN?>">
<input type=hidden name="txtname" value="<?=$txtname?>">
<input type=hidden name="txtauthor" value="<?=$txtauthor?>">
<input type=hidden name="curPg" >
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -