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

PHPä¯ÀÀ±íÖеļǼ

Òªä¯ÀÀ±íÖеļǼÐèÒªÖ´ÐÐÒÔϼ¸²½²Ù×÷£º
(1) Ö´ÐÐÒÔÏÂSQLÓï¾ä£º
select field1,field2,field3,...from $table_name
ÆäÖÐfield1,field2,field3±íʾµÄÊÇÐèÒª´Ó±íÖвéѯµÄ×Ö¶ÎÃû³Æ£º$table_nameΪ±íµÄÃû³Æ¡£
(2)ʹÓÃPHP MSSQLÀà¿âÖеÄmssql_fetch_array()º¯Êý¶ÁÈ¡Ö´ÐÐSQLÓï¾äËù·µ»ØµÄ½á¹û¼¯¡£¸Ãº¯ÊýµÄÓï·¨¸ñʽÈçÏ´úÂ룺
mssql_fetch_array(resource result [,int result_type])
ÆäÖвÎÊýresultΪº¯Êýmssql_query()ËùÖ´ÐеÄSQL½á¹û¼¯£»²ÎÊýresult_typeΪ·µ»Ø½á¹ûÊý×éµÄÀàÐÍ£¬Ä¬ÈÏΪ¼È¿ÉÒÔÓÃÊýÖµÒ²¿ÉÒÔÓÃ×Ö¶ÎÃû×÷Êý×éÔªËØ¡£¸Ãº¯Êý½«·µ»ØÒ»¸ö½á¹ûÊý×é¡£
ÁíÍ⻹¿ÉÒÔÓÃmssql_num_rows()º¯ÊýÀ´»ñÈ¡½á¹û¼¯ÖмǼµÄÊýÄ¿¡£¸Ãº¯Êý¸ñʽ£º
mssql_num_rows(resource result)
ÒÔÉÏ´úÂëÖвÎÊýresultΪº¯Êýmssql_query()ËùÖ´ÐеÄsql½á¹û¼¯¡£¸Ãº¯Êý½«¸ù¾Ý½á¹û¼¯µÄÐÐÊý£¬·µ»ØÏàÓ¦µÄÊýÖµ¡£
(3)ͨ¹ýwhileÑ­»·¶Á³ö½á¹û¼¯ÖеÄÿÌõ¼Ç¼¡£
<?php
$hostname="datahost";
$dbuser="sa";
$dbpasswd="123";
$dbname="tempdb";
$conn=mssql_connect($datahost,$dbuser,$dbpasswd);
mssql_select_db($dbname);
$t_name="my_table";
$select_t="select id,name from $t_name";
$result=mssql_query($select_t,$conn);
$re_num=mssql_num_rows($result);
echo"<font color=#666666>±íÖÐÄ¿Ç°¹²ÓмǼ</font>";
echo "<strong><font color=green>".$re_num."</font></strong>";
echo "<font color=#666666>Ìõ</font>";
echo "<p>";
while ($rows=mssql_fetch_array($result))
{
     echo  "<font color=#666666>±àºÅ£º</font><strong><font color=green>".$rows[id]."</font></strong>";
     echo  "<font color=#666666>ÐÕÃû£º</font><strong><font color=green>".$rows[name]."</font></strong>";
      echo "<p>";
}
mssql_close($conn);
?>
½á¹ûÑÝʾ£ºhttp://mingking.limewebs.com/db/select_fields.php


Ïà¹ØÎĵµ£º

PHP MVC ³õ̽

ÏÐÀ´Óпգ¬Ñ§Ï°Ò»ÏÂPHPµÄMVCģʽ£¬³äʵһÏÂ×ÔÎÒ£¬²»ÖÁÓÚÂäºó¡£¿´Á˸ö¼òµ¥µÄʾÀý
£¬×öµã¼Ç¼¡£
µ¥µãÈë¿Ú£º
1. ËùÓгÌÐò¶¼ÊÇͨ¹ýindex.phpÀ´½øÐе÷Óõģ¬ÕâÒª¿¿.htaccessÎļþÀ´½øÐпØÖÆ¡£
2. URL router¿ÉÒÔÓɵ¥¶ÀµÄRouterÀàÀ´½øÐÐControllerµÄÑ¡Ôñ£¬Ò²¿ÉÒÔ·ÅÔÚindex.phpÖнøÐÐÑ¡Ôñ¡£
3. Config×îºÃ·Åµ½µ¥¶ÀµÄÎļþÖУ¬½á ......

windowsÏÂPHP5+APACHE+MYSQLÍêÕûÅäÖÃ

Èí¼þ°æ±¾:
php-5.2.13-Win32
apache_2.2.9-win32-x86-no_ssl-r2.msi(×¢Ò⣺APACHE 2.2.X°æ±¾ÒÔÉÏÒªÔö¼Ó²å¼þ²ÅÖ§³ÖPHP 5µÄ)
mysql-5.1.44-win32.msi
ÏÈ×°µÄphp5,Ö±½Ó½âѹÎļþµ½C:\php(°²×°µ½ÄÄÀï²¢²»»áÓÐÓ°Ï죬ƾ¸öÈËϲºÅ£¬±¾ÎÄÖеÄËùÓз¾¶¶¼ÒÔÎҵݲװ·¾¶£¬Çë´ó¼ÒÔÚ×Ô¼ºµÄ»úÆ÷ÉÏ°²×°µÄʱºò×¢ÒâÐÞ¸ÄΪ×Ô¼ºµÄ·¾¶)
½Ó× ......

php»ñÈ¡·þÎñÆ÷ʱ¼ä

ºÜ¶àʱºòÎÒÃÇϲ»¶ÓÃjsÀ´»ñÈ¡ÈÕÆÚºÍʱ¼ä£¬µ«Õâ½ö½öÊÇ¿Í»§¶ËµÄ¡£
ÎÒÃÇ¿ÉÒÔÓÃphpµÄdateº¯Êý¼´¿ÉÀ´»ñÈ¡·þÎñÆ÷ÉϵÄʱ¼ä£º
 <?php
//½«Ê±ÇøÉèÖÃΪÖйú
date_default_timezone_set("PRC");
echo date("Y-m-d l H:i:s A");
//ÀýÊä³ö£º2010-03-06 Saturday 11:51:29 AM
?> ......

phpÖеÄÒýÓÃ

PHPÖÐÒýÓÃÖ¸µÄÊDz»Í¬µÄÃû×Ö·ÃÎÊͬһ¸ö±äÁ¿ÄÚÈÝ. µ«ÕâÓë£ÃÓïÑÔÖеÄÖ¸ÕëÊÇÓвî±ðµÄ£®£ÃÓïÑÔÖеÄÖ¸ÕëÀïÃæ´æ´¢µÄÊDZäÁ¿µÄÄÚÈÝÔÚÄÚ´æÖдæ·ÅµÄµØÖ·¡£
¹ØÓÚ¶Ô±äÁ¿£¬º¯Êý»òÕßÀàµÄÒýÓò»¶à˵£¬µ«ÒªËµÒ»ÏÂunsetÒ»¸öÒýÓã¬Ê¾Àý£º
<?php
$a = "hello";
$b =&$a;
unset($b);
echo '$a:'.$a;
//output:$a:hello
?> ......

PHP ÔÚÊý¾Ý¿âÖд´½¨±í

Á¬½Óµ½Êý¾Ý¿âÖ®ºó£¬¼´¿ÉÔÚÊý¾Ý¿âÖд´½¨ËùÐèÒªµÄ±í¡£ÔÚÊý¾Ý¿âÖд´½¨±í£¬¿ÉÒÔͨ¹ýÊÇÓÃPHPµÄMSSQL¿âº¯ÊýÖеÄmssql_query()º¯ÊýÖ´ÐÐÏàÓ¦µÄ½¨±íSQLÓï¾äÀ´ÊµÏÖ¡£º¯Êýmssql_query()ÊÇרÃÅÓÃÓÚÖ´ÐÐSQLÓï¾äµÄº¯Êý£¬¸Ãº¯Êý´úÂë¸ñʽ£º
mixed  mssql_query(string query[,resource link_identifier[,int batch_size]])
¸Ãº¯Êý²ÎÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ