Ò»¸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¯ÀÀÆ÷¡£