PHP ·ÖÒ³
·ÂGOOGLEºÍDiscuz·ÖÒ³º¯Êý(php)
Õâ¸öº¯ÊýÖ»ÐèÒª2¸ö²ÎÊý µ±Ç°Ò³ÂëºÍ×ÜÒ³Êý,$siteÊÇ·¾¶,ÎļþÃû¿ÉÒÔ°´×Ô¼ºµÄÐèÒªÐÞ¸Ä
Õâ¸öº¯Êý²»ÄÜ´«µÝÆäËû²ÎÊý,Èç¹ûÒª´«µÝÆäËû²ÎÊý,ÔÚº¯ÊýÀï×Ô¼º¼ÓÒ»¸ö²ÎÊý¾ÍÐÐÁË
<?php
//¼ÆÊý
$sql = “SELECT count(*) from `andycms_title`;”;
$numrs = mysql_query($sql) or die(mysql_error());
$numrow = mysql_fetch_row($numrs);
$num = $numrow[0]; //×ܼǼ
$total = ceil($num / $perpage); //×ÜÒ³Êý
//µ±Ç°Ò³Âë
if(!isset($_GET[‘page’]) preg_match(‘~[^0-9]+~’,($_GET[‘page’])) $_GET[‘page’] <= 0 $_GET[‘page’] > $total) $page = 1;
else $page = $_GET[‘page’];
$startnum = ($page-1) * $perpage; //¼Ç¼¼¯¿ªÊ¼Êý
?>
<?php
// Andy·ÖÒ³º¯Êý
function fenye ($p,$total)
{
global $site;
$prevs = $p - 10; if ( $prevs <= 0) { $prevs = 1; }
$prev = $prevs - 1; if ( $prev <= 0) {$prev = 1;}
$nexts = $p + 9; if ( $nexts > $total) { $nexts = $total; }
$next = $nexts + 1; if ( $next > $total) {$next = $total;}
$pagenavi = “<a href=\”$site/?page=1\”>Ê×Ò³</a> “;
$pagenavi.= “<a href=\”$site/?page=$prev\”>ÉÏÒ³</a> “;
for ( $i = $prevs; $i <= $p-1; $i++ ) {
$pagenavi.= “<a href=\”$site/?page=$i\”>$i</a> “;
}
$pagenavi.= “<strong>$p</strong> “;
for ( $i = $p+1; $i <= $nexts; $i++ ) {
$pagenavi.= “<a href=\”$site/?page=$i\”>$i</a> “;
}
$pagenavi.= “<a href=\”$site/?page=$next\”>ÏÂÒ³</a> “;
$pagenavi.= “<a href=\”$site/?page=$total\”>βҳ</a> “;
return $pagenavi;
}
?>
Ч¹û:
page=1
Ê×Ò³ ÉÏÒ³ 1 2 3 4 5 6 7 8 9 10 ÏÂÒ³ βҳ
page=10
Ê×Ò³ ÉÏÒ³ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ÏÂÒ³ βҳ
page=20
Ê×Ò³ ÉÏÒ³ 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Ïà¹ØÎĵµ£º
phpÁ¬½Ómysql²âÊÔ´úÂ룺
$link=mysql_connect('localhost','root','123456');
if(!$link) echo "ʧ°Ü!";
else echo "³É¹¦!";
mysql_close();
?>
ÔËÐдúÂë³öÏÖ£ºCall to undefined function 'mysql_connect()'… ʧ°Ü
°Ù¶ÈÕÒµ½½á¹ûÊÇPHP+MYSQL »·¾³Ã ......
<?php
function delfile($dir,$n) //ɾ³ýDIR·¾¶ÏÂNÌìÇ°´´½¨µÄËùÓÐÎļþ;
{
if(is_dir($dir))
{
if($dh=opendir($dir))
{
while (false !== ($file = readdir($dh)))
{
if($file!="." && $file!="..")
{
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) ......
/ ok
header('HTTP/1.1 200 OK');
//ÉèÖÃÒ»¸ö404Í·:
header('HTTP/1.1 404 Not Found');
//ÉèÖõØÖ·±»ÓÀ¾ÃµÄÖض¨Ïò
header('HTTP/1.1 301 Moved Permanently');
//תµ½Ò»¸öеØÖ·
header('Location: http://www.example.org/'
);
//ÎļþÑÓ³ÙתÏò:
header('Refresh: 10; url=http://www.example.org/');
print 'Y ......
phpÑéÖ¤ÂëÏÔʾºìÉ«²æ²æ
Õâ¸öÎÊÌâÀ§ÈÅÎÒ°ëÌìÁË¡£ÔÚ±¾»úÉϲâÊÔÊÇÕý³£µÄ£¬»·¾³ÊÇwin2003+php+mssql.ÏÔʾÕý³£¡£
ÏÖÔÚÎҰѳÌÐòתÒƵ½Ð·þÎñÆ÷ÉÏ£¬ÑéÖ¤Âë¾Í²»ÏÔʾÁË£¬²»ÖªµÀÊÇʲôÇé¿ö£¬ÎÒ¼ì²âÁË·þÎñÆ÷»·¾³£¬gdÊÇÖ§³ÖµÄ£¬ÈçÏÂͼ:
µ«ÊÇ£¬¾ÍÊDz»ÏÔʾ£¬ÈçÓиßÊÖ£¬Çë¸úÌû£¬Ð»Ð»ÁË¡£ ......