一不小心弄到了kk66.com(雅客)的一部分代码,大家看看希望有帮助
<?php
// ------------------------------ -------- ------------------------------ //
require ("./include/config.inc.php");
require ("./global.php");
include ("./include/header.php");
// ------------------------------ -------- ------------------------------ //
mysql_connect($dbhost,$dbuser,$dbpasswd) or die ("数据库连接失败");
echo "<title>".$site_name." - 下载系统 - powered by yemao.net</title>\n";
echo "<center>\n";
echo "<br><table border=0 cellpadding=3 cellspacing=0 style='border-collapse:c
ollapse' bordercolor=#efefef width=735>\n";
echo "<tr>\n";
echo "<td valign=bottom nowrap>";
// 本类/总数 ------------------------------
all_and_this();
// 搜索表单 ------------------------------
echo "</td>\n";
echo "<form method=POST action=list.php>\n";
echo "<td align=center valign=bottom nowrap>\n";
echo "<img src='./images/search.gif' width=16 heigth=16> ";
echo "名称<input type=checkbox name=name value='1'checked ";
echo ($name == 0 ? '' : checked);
echo ";>\n";
echo "简介<input type=checkbox name=brief value='1'checked ";
echo ($brief == 0 ? '' : checked);
echo ">\n";
echo "<input class=border type=text name=keyword size=12>\n";
echo "<select size=1 name=searchtype class=border>\n";
echo "<option value=0 selected>--==所有程序==--</option>\n";
// 查询大类
$typesql1 = "SELECT COUNT(*) AS rcnt FROM $down_sort1_table ORDER BY id";
$typeresult1 = mysql_db_query($dbname, $typesql1);
$typerow1 = mysql_fetch_array($typeresult1);
$typesql1 = "SELECT * FROM $down_sort1_table ORDER BY id";
$typeresult1 = mysql_db_query($dbname, $typesql1);
while ($typerow1 = mysql_fetch_array($typeresult1)){
$sort1id = $typerow1[id];
echo "<option>----".$typerow1[sort1]."----</option>\n";
// 查询小类
$typesql2 = "SELECT COUNT(*) AS rcnt FROM $down_sort2_table WHERE sort1id='$so
rt1id' ORDER BY id";
$typeresult2 = mysql_db_query($dbname, $typesql2);
$typerow2 = mysql_fetch_array($typeresult2);
$typesql2 = "SELECT * FROM $down_sort2_table WHERE sort1id='$sort1id' ORDER BY
id";
$typeresult2 = mysql_db_query($dbname, $typesql2);
while ($typerow2 = mysql_fetch_array($typeresult2)){
if ($type == $typerow2[id]):
echo "<option value='".$typerow2[id]."' selected>".$typerow2[sort2]."</option>
\n";
else:
echo "<option value='".$typerow2[id]."'>".$typerow2[sort2]."</option>\n";
endif;
} // while sort2
} // while sort1
echo "</select> \n";
echo "<input bgcolor=#efefef type=submit value=搜索 name=search class=border>\
n";
echo "</td></form>";
// 跳转分类 --------------------------
goto($type);
echo "</tr>\n";
echo "</table>\n";
echo "<br>\n";
// ------------------------------
echo "<table border=0 cellspacing=0 style='border-collapse:collapse' width=735
height=233 cellpadding=3>\n";
echo "<tr>\n";
echo "<td width=550 height=233 valign=top>\n";
// 转到搜索 ------------------------------
if ($search):
search($keyword,$searchtype,$name,$brief);
end;
else:
// 列出页数 ------------------------------
echo "<table border=1 cellpadding=3 cellspacing=0 style='border-collapse:colla
pse' bgcolor=white bordercolor=#C0C0C0 width=100%>\n";
echo "<tr>\n";
echo "<td width=100% align=right class=shadow2>\n";
list_pages($type,$setpage,$setid);
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br>\n";
// 程序列表 ------------------------------
list_program($type,$setid);
// 列出页数 ------------------------------
echo "<table border=1 cellpadding=3 cellspacing=0 style='border-collapse:colla
pse' bordercolor=#C0C0C0 width=100%>\n";
echo "<tr>\n";
echo "<td width=100% align=right class=shadow2>\n";
list_pages($type,$setpage,$setid);
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br>\n";
endif; // if search
// 排行显示 ------------------------------
echo "</td>\n";
echo "<td bgcolor=#f7f7f7 width=185 height=233 valign=top align=right>\n";
down_type_top10($type);
view_top10();
down_top10();
include ("./include/k666.php");
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><hr width=735>\n";
mysql_close();
// ------------------------------ -------- ------------------------------ //
include ("./include/footer.php");
// ------------------------------ -------- ------------------------------ //
?>
它的条理还是比较清楚的,而且里面包含了分页,查询的一些代码,希望会有帮助
更重要的,它的查询速度还是很快的。可以从这里面看看它的数据库的结构
浅妄薄见,望与斟酌