Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

php+mysql·ÖÒ³


·ÖÒ³¹¦ÄܵÄʵÏÖÊÇÿÖÖWEB¿ª·¢ÓïÑÔ±ØÐëҪʵÏֵŦÄÜ¡£PHPÒ²ºÃ,JSPÒ²°Õ¡£ÎÒ×¼±¸ÓÃÁ½¸ö·½·¨À´²ûÊöPHP+MYSQLʵÏÖ·ÖÒ³µÄ¹¦ÄÜ¡£
 
Ò»¡¢·ÖÒ³³ÌÐòµÄÔ­Àí
·ÖÒ³³ÌÐòÓÐÁ½¸ö·Ç³£ÖØÒªµÄ²ÎÊý£ºÃ¿Ò³ÏÔʾ¼¸Ìõ¼Ç¼£¨$pagesize£©ºÍµ±Ç°Êǵڼ¸Ò³£¨$page£©¡£ÓÐÁËÕâÁ½¸ö²ÎÊý¾Í¿ÉÒԺܷ½±ãµÄд³ö·ÖÒ³³ÌÐò£¬ÎÒÃÇÒÔMySqlÊý¾Ý¿â×÷ΪÊý¾ÝÔ´£¬ÔÚmysqlÀïÈç¹ûÒªÏëÈ¡³ö±íÄÚij¶ÎÌØ¶¨ÄÚÈÝ¿ÉÒÔʹÓõÄSQLÓï¾ä£ºselect * from table limit offset,rowsÀ´ÊµÏÖ¡£ÕâÀïµÄoffsetÊǼÇÂ¼Æ«ÒÆÁ¿£¬ËüµÄ¼ÆËã·½·¨ÊÇoffset(ϱêÒâ˼)=$pagesize*($page-1)£¬rowsÊÇÒªÏÔʾµÄ¼Ç¼ÌõÊý£¬ÕâÀï¾ÍÊÇ$page¡£Ò²¾ÍÊÇ˵select * from table limit 10,10ÕâÌõÓï¾äµÄÒâ˼ÊÇÈ¡³ö±íÀï´ÓµÚ11Ìõ¼Ç¼¿ªÊ¼µÄ20Ìõ¼Ç¼¡£
 
¶þ¡¢Ö÷Òª´úÂë½âÎö
<?php
$conn=mysql_connect("localhost","root","123");//Á¬½ÓÊý¾Ý¿â
$rs=mysql_query("select count(*) from tb_product",$conn); //È¡µÃ¼Ç¼×ÜÊý$rs
$pagesize=10; //ÉèÖÃÿһҳÏÔʾµÄ¼Ç¼Êý
$myrow = mysql_fetch_array($rs);
$numrows=$myrow[0];
$pages=intval($numrows/$pagesize);//¼ÆËã×ÜÒ³Êý
 
 
?>
 
Èý ÍêÕû´úÂë
£¼html£¾
£¼head£¾
£¼title£¾php·ÖҳʾÀý£¼/title£¾
£¼meta http-equiv="Content-Type" content="text/html; charset=gb2312"£¾
£¼/head£¾
£¼body£¾
£¼?php
¡¡$conn=mysql_connect("localhost","root","");
¡¡//É趨ÿһҳÏÔʾµÄ¼Ç¼Êý
¡¡$pagesize=1;
¡¡mysql_select_db("mydata",$conn);
¡¡//È¡µÃ¼Ç¼×ÜÊý$rs£¬¼ÆËã×ÜÒ³ÊýÓÃ
¡¡$rs=mysql_query("select count(*) from tb_product",$conn);
¡¡$myrow = mysql_fetch_array($rs);
¡¡$numrows=$myrow[0];
¡¡//¼ÆËã×ÜÒ³Êý
¡¡$pages=intval($numrows/$pagesize);
¡¡if ($numrows%$pagesize)
¡¡¡¡$pages++;
¡¡//ÉèÖÃÒ³Êý
¡¡if (isset($_GET['page'])){
¡¡¡¡$page=intval($_GET['page']);
¡¡}
¡¡else{
¡¡¡¡//ÉèÖÃΪµÚÒ»Ò³
¡¡¡¡$page=1;
¡¡}
¡¡//¼ÆËã¼ÇÂ¼Æ«ÒÆÁ¿
¡¡$offset=$pagesize*($page - 1);
¡¡//¶Áȡָ¶¨¼Ç¼Êý
¡¡$rs=mysql_query("select * from myTable order by id desc limit $offset,$pagesize",$conn);
¡¡if ($myrow = mysql_fetch_array($rs))
¡¡{
¡¡¡¡$i=0;
¡¡¡¡?£¾
¡¡¡¡£¼table border="0" width="80%"£¾
¡¡¡¡£¼tr£¾
¡¡¡¡¡¡£¼td width="50%" bgcolor="#E0E0E0"£¾
¡¡¡¡¡¡¡¡£¼p align="center"£¾±êÌ⣼/td£¾


Ïà¹ØÎĵµ£º

PHP Floating point precision

Floating point precision
It is typical that simple decimal fractions like 0.1
or
0.7
cannot be converted into their internal binary
counterparts without a small loss of precision. This can lead to
confusing
results: for example, floor((0.1+0.7)*10)
will usually
return 7
......

ÖØÈ¼ÄãµÄPHP°²È«Ö®»ð

¶ÔÓڽű¾°²È«Õâ¸ö»°ÌâºÃÏñÓÀԶûÍêûÁË£¬Èç¹ûÄã¾­³£µ½¹úÍâµÄ¸÷ÖÖ¸÷ÑùµÄbugtraqÉÏ£¬Äã»á·¢ÏÖÓÐÒ»°ëÒÔÉ϶¼ºÍ½Å±¾Ïà¹Ø£¬ÖîÈçSQL
injection£¬XSS£¬Path Disclosure£¬Remote commands
executionÕâÑùµÄ×ÖÑ۱ȱȽÔÊÇ£¬ÎÒÃÇ¿´ÁËÖ®ºóµÄÓÃ;ÄѵÀ½ö½öÊÇ×¥È⼦?¶ÔÓÚÎÒÃÇÏë×öweb°²È«µÄÈËÀ´Ëµ£¬×îºÃ¾ÍÊÇÄÃÀ´Ñ§Ï°£¬¿ÉÊÇÍòÎï×¥¸ùÔ´£¬ÎÒà ......

ÅäÖÃApacheµÄ·ÃÎÊĿ¼£¨for PHP£©

       ÔÚĬÈÏÇé¿öÏ£¬phpµÄÏîÄ¿ÐèÒª½¨ÔÚApache Group\Apache\htdocsĿ¼Ï²ſÉÒÔÕý³£·ÃÎÊ¡£µ±ÎÒÃÇÐèÒª×Ô¼º½¨Á¢Ò»¸ö²»ÔÚApache Group\Apache\htdocsĿ¼ÏµĹ¤×÷Çø¼äʱ£¬¾ÍÐèÒª¸Ä±äApacheµÄ·ÃÎÊÖ¸¶¨Â·¾¶¡£°²×°ºÃApache ºó£¬ÔÚApache Group\Apache\conf ÏÂÓÐÒ»¸öÎļþhttpd.conf£¬ËüÀïÃæ°üº¬×Å ......

php mysql ÅäÖÃphp.ini

Îļþphp.ini·ÅÈëwindowsÏ£¬½«ÏÂÃæÄÚÈÝ¿½±´µ½¼Çʱ¾ÃüÃûΪphp.ini·ÅÈëc:/windowsÏÂ,ÖØÆôApache server£º
[PHP]
;;;;;;;;;;;
; WARNING ;
;;;;;;;;;;;
; This is the default settings file for new PHP installations.
; By default, PHP installs itself with a configuration suitable for
; development purposes ......

mysql ´íÎó×ܽá

Can't open the mysql.plugin table. Please run mysql_upgrade to create it
µ±Åöµ½ÕâÑùµÄ´íÎóÊÇûÓгõʼ»¯mysqlÊý¾Ý¿â,¿ÉÒÔÔËÐÐÈçϽű¾¾Í¿ÉÒÔ½â¾ö
cd /opt/mysql-5.1.46
cd scripts/
./mysql_install_db --user=mysql --datadir=/usr/local/mysql/var/
ÔËÐÐÈçϵĴúÂë¾Í¿ÉÒÔ½â¾öÉÏÊöÎÊÌâ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ