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 ......
Session¼ò½é
session ·Ö³ÉÁ½²¿·Ö£¬session¿Õ¼ä´æ·ÅÓÚ·þÎñÆ÷¶Ë£¬´ò¿ª¿Õ¼äµÄID ´æ·ÅÓÚ ¿Í»§¶ËµÄcookie£¬ Èç¹û¿Í»§¶Ë¹Ø±ÕÁËcookie£¬session¾Í²»ÄÜÕý³£µÄʹÓá£
SessionµÄÖÐÎÄÒëÃû½Ð×ö“»á»°”£¬Æä±¾À´µÄº¬ÒåÊÇÖ¸ÓÐʼÓÐÖÕµÄһϵÁж¯×÷/ÏûÏ¢£¬±ÈÈç´òµç»°Ê±´ÓÄÃÆðµç»°²¦ºÅµ½¹Ò¶Ïµç»°ÕâÖмäµÄһϵÁйý³Ì¿ÉÒÔ³Æ ......
×öPHP³ÌÐòµÄÈ˶¼ÖªµÀhtmlentitiesºÍhtmlspecialcharsº¯Êý£¬¶¼ÊǸñʽ»¯html´úÂëµÄ£¬µ«ÊÇÕâ¶þ¸öº¯ÊýÊÇ·ñÕæµÄ¹¦ÄÜÒ»ÑùÂ𣿠php³ÌÐòÔ±Ö®¼Ò ÕâÁ½¸öº¯ÊýÔÚ¸ñʽ»¯´øÓÐÓ¢ÎÄ×Ö·ûµÄhtml´úÂëµÄʱºò»ù±¾Ã»É¶ÎÊÌ⣬µ«ÊÇhtmlentities¶ÔÖÐÎÄ×Ö·ûÒ²²»·Å¹ý£¬ÕâÑùµÃ³öÀ´µÄ½á¹ûÊÇÖÐÎÄ×Ö·û²¿·Ö±äΪһ¶ÑÂÒÂë¡£µ±Ê±×öÓ¢ÎÄÕ¾µÄʱºò¸ù±¾¾Íû¾õ²ìµ ......
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);
}
......