業餘問題,但我一直在想。什麼是從MySQL查詢中選擇一行的PHP?你正在用唯一的ID選擇一些東西(你知道只有一行符合你的請求)並且只想得到那個值。你還需要使用while循環和mysql_fetch_row嗎?從MySQL返回一行
$query = "SELECT name,age FROM people WHERE uid = '2'";
$result = mysql_query($query);
// what php is used to return the name and age? preferably without a loop?
如PHP手冊爲['的mysql_query()'](http://php.net/manual/en陳述/function.mysql-query.php)函數:*不推薦使用這個擴展名。相反,[MySQLi](http://www.php.net/manual/en/book.mysqli.php)或[PDO_MySQL](http://www.php.net/manual/en/ref.pdo-應該使用mysql.php)擴展名。另請參見[MySQL:選擇API](http://www.php.net/manual/en/mysqlinfo.api.choosing.php)指南和[相關FAQ](http://www.php.net/manual /en/faq.databases.php#faq.databases.mysql.deprecated)獲取更多信息。* – eggyal