📄 category.php
字号:
<html>
<head>
<title>InterShop-Category</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
td { font-size: 11px}
a:link { font-size: 11px; text-decoration: none}
a:active { font-size: 11px; text-decoration: none}
a:hover { font-size: 11px; text-decoration: none}
a:visited { font-size: 11px; text-decoration: none}
-->
</style>
<script language=javascript>
//----BEGIN implement for paging----------//s
function GotoPage(iPage) {
document.form1.curPg.value=iPage
document.form1.submit()
}
</script>
</head>
<body >
<form action="category.php" method=post name=form1>
<table width="500" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td valign="top" >
<?php
require("../dbcon.inc");
$sotrang=5;
$record=5;
$totalRows = 0;
$paging="";
$stSQL ="select c.CateID,c.CateName,";
$stSQL .= " count(b.CateID) as itemno from tblBooks b,tblcategories c ";
$stSQL .= "where b.CateID=c.CateID ";
$stSQL .= "Group by c.CateID,c.CateName ";
$stSQL .= "order by c.CateName";
$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);
$curPg=(isset($curPg))?$curPg:1;
if($curPg=="")
$curPg =1;
$curRow = ($curPg-1)*$maxRows+1;
$paging ="Current Page : <font color=red>".$curPg."</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)(($curPg-1)/$maxPages))* $maxPages) && ($i<=((int)(($curPg-1)/$maxPages+1))* $maxPages))
{
if($start==1) $start=$i;
if($i==$curPg)
$paging1 .= $i." ";
else
$paging1 .= "<a href='javascript:GotoPage(".$i.")'>".$i."</a> ";
$end=$i;
}
}
$paging.= "Go to page : " ;
if($curPg>$maxPages)
$paging .="<a href='javascript:GotoPage(".($start-1).")'>Previous</a> ";
$paging.=$paging1;
if(((($curPg-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>All of Categories</font></b></td>
<td align=right><a href="search.php">Back to Search</a></td>
</tr>
<tr><td align=left><font face="Arial" color="#0066cc">Tổng
số Category 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="15%" height="14" align="middle"><font face="Arial" color="#ff6600">Category No</font></td>
<td width="45%" height="14"><font face="Arial" color="#ff6600">Category Name</font></td>
<td width="40%" height="14"><font face="Arial" color="#ff6600">Number of Items</font></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 <= $curPg*$maxRows))
{
$curRow++;
if($curRow>$low)
{
$cateid=$row["CateID"];
$catename=$row["CateName"];
$itemno=$row["itemno"];
$i+=1;
?>
<tr valign="top">
<td align="middle"><font face="Arial" color="#0066cc">
<?=$cateid?>
</font> </td>
<td ><font face="Arial" color="#0066cc">
<A href="listofitem.php?cateid=<?=$cateid?>&catename=<?=$catename?>">
<?=$catename?>
</A></font></td>
<td ><font face="Arial" color="#0066cc">
<?=$itemno?>
</font></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!
Category not found! </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ố Category 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="curPg" >
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -