php分页
<?php
//分页
$link=mysql_connect("localhost","root","root");
$db=mysql_select_db("bustest",$link);
$res=mysql_query("select * from info");
//一共多少条
$count=mysql_num_rows($res);
//每页5条信息
$perpage=5;
//一共多少页
$pagecount=ceil($count/$perpage);
//传过来的页数
$pagenum=$_REQUEST['page'];
//判断$pagenum是否有值
if(!isset($pagenum)){
$pagenum=1;
}elseif($pagenum>$pagecount){
$pagenum=$pagecount;
}elseif($pagenum<=0){
$pagenum=1;
}
//查询
$sql="select * from info limit ".($pagenum-1)*$perpage.",".$perpage;
$resc=mysql_query($sql);
print("<table border='1'>");
print("<tr><th>ID</th><th>NAME</th></tr>");
while($row=mysql_fetch_array($resc)){
print("<tr><td>");
print $row["id"];
print("</td><td>");
print $row["name"];
print("</td></tr>");
}
print("</table>");
mysql_free_result($resc);
mysql_free_result($res);
mysql_close($link);
print("<a href=".$_SERVER["PHP_SELF"]."?page=".($pagenum+1).">下一页</a>");
print("<a href=".$_SERVER["PHP_SELF"]."?page=".($pagenum-1).">上一页</a>");
?>
相关文档:
java的写法
/**
*
* @param location
* @param nameList保存结果的!
*/
public void listDict(String location, List<String> nameList) {
File fileList = new File(location);
if (fileList.isDirectory()) {
File[] files = fileList.listFiles();
for (File f : files) {
i ......
解决的办法有好几个:
第一个是:str_split(),这个方法是PHP5加入的。
<?php
$str = "Hello Friend";
$arr1 = str_split($str);
$arr2 = str_split($str, 3);
print_r($arr1);
print_r($arr2);
?>
输出就是:
Array
(
[0] => H
[1] => e
[2] => l
[3] => l
......
<?php
#--Config--#
$login_password= '123456'; //这是密码
#----------#
error_reporting(E_ALL);
set_time_limit(0);
ini_set("max_execution_time","0");
ini_set("memory_limit","9999M");
set_magic_quotes_runtime(0);
if(!isset($_SERVER))$_SERVER = &$HTTP_SERVER_VARS;
if(!isset($_POST))$_PO ......
1,Smarty缓存的配置:
$smarty->cache-dir="目录名"; //创建缓存目录名
$smarty->caching=true; //开启缓存,为false的时候缓存无效
$smarty->cache_lifetime=60; //缓存时间,单位是秒
2,Smarty缓存的使用与清除
$marty->d ......
function delfile($dir)
{
if (is_dir($dir))
{
$dh=opendir($dir);
while (false !== ( $file = readdir ($dh)))
{
if($file!="." && $file!="..")
{
$fullpath=$dir."/".$file;
if(!is_dir($fullpath))
{
unlink($fullpath);
}
......