Ò»¸ö¼òµ¥µÄ×Ô¶¯·¢ËÍÓʼþϵͳ(Èý)

5年以前  |  阅读数:423 次  |  编程语言:PHP 

Ò»¸o¼oµ¥µÄ×Ô¶¯*¢ËÍÓʼþϵͳ£¨Èý£(C)

ÕaÀi½eÉÜphpºÍmysql½aºÏÆðÀ´ÊµÓá£ÈçºÎ´ÓmysqlÊý¾Ý¿aÖÐÌaÈ¡Êý¾Ý¡£   

ºÃ£¬ÎÒÃÇÒѾ­³É¹¦µÄÍe³ÉÁËÎÒÃǵÄÒªÇo£¬ºÜ¶aµÄÊý¾ÝÒѾ­´aeÔÚÁËÊý¾Ý¿aÖУ¬ÏÖÔÚµÄÎÊÌaÊÇ£¬ÈçºÎ²eѯÕaÐ(C)Êý¾Ý£¬µÃµ½ÓÐÓõĽa¹uÄØ£¿   

ÔÚÏÂÃaeµÄ³ÌÐoÖУ¬ÎÒÃǽ«Ñ¡Ôñ"apple"µÄÓû§Êa³o¡£

--------------------------------------------------------

<?

/ ÉuÃ÷Ò»Ð(C)±ØÐeµÄ±aÁ¿/

$hostname = "yourhostname";
$username = "yourusername";
$password = "yourpassword";
$userstable = "information"; / ʹÓÃMySQL½¨Á¢µÄÊý¾Ý±i´aeÈ¡ÐÅÏ¢ /
$dbName = "yourdbname";

/ ÓeÊý¾Ý¿aÁ¬½Ó/
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");

@mysql_select_db( "$dbName") or die( "Unable to select database");

/ Ñ¡ÔñËuÓС°apple¡±Óû§/

$query = "SELECT * FROM $userstable WHERE (preference LIKE 'Apples') ";

$result = MYSQL_QUERY($query);

/ ͳ¼ÆÓжaÉÙÕaÑuµÄÓû§/

$number = MYSQL_NUMROWS($result);

/ Êa³o½a¹u/

$i = 0;

IF ($number == 0) :

PRINT "<CENTER><P>Nobody in the database prefers Apples!</CENTER>";   

ELSEIF ($number > 0) :

PRINT "<CENTER><P>Users preferring Apples: $number<BR><BR>";   

WHILE ($i < $number):   

    $name = mysql_result($result,$i,"name");   
    $email = mysql_result($result,$i,"email");   

    PRINT "Visitor $name likes Apples.<BR>";   
    PRINT "Email address: $email.";   
    PRINT "<BR><BR>";   

    $i++;   

ENDWHILE;   

    PRINT "</CENTER>";   

ENDIF;

?>

--------------------------------------------------------

½«Ëu´aeΪapples.php3

½aÊÍ˵Ã÷£ºÒ»Ð(C)ÐÂÓõ½µÄº¯Êý£º

1¡¢$number = MYSQL_NUMROWS($result);

Ói*¨£ºint mysql_num_rows(string result);

¡¤result ´Óº¯Êýmysql_queryÖе»ØµÄÊý×e¼Ç¼¡£
¡¤
µ»Ø´aeÔÚ$resultÖеÄÐÐÊý¡£

2¡¢$name = MYSQL_RESULT($result,$i,"name");

Ói*¨: int mysql_result(int result, int i, column);

Õa¸oº¯Êý½«*ÖÀe¼Ç¼£¬½«Ã¿Ò»Ìo¸³Öµ¸ø±aÁ¿¡£
¡¤$resultÊÇÖ¸ÖеÄÊý×e½a¹u¡£
¡¤$iÊÇÖ¸Êý¾ÝµÄÐС£
¡¤columnÊÇÖ¸mysqlÊý¾Ý±iÖÐÁеÄÃu×Ö¡£Ò²¿ÉÒÔʹÓñaÁ¿¡£

Òo´ËʹÓÃÒ»¸o¼oµ¥µÄwhileÑ­»*£¬ÎÒÃǾÍÄܺÜÈÝÒ׵Ľ«Êý¾ÝÊa³o¸øa¯ÀÀÆ÷¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例