PHP+;MariaDB-让PHP只显示一次MySQL结果?
我对网络开发非常陌生,所有的新东西我都必须链接在一起。我试图让这个简单的MySQL+PHP脚本工作,但是,我似乎得到了重复2次的结果 这是我的结果。PHP+;MariaDB-让PHP只显示一次MySQL结果?,php,mysql,Php,Mysql,我对网络开发非常陌生,所有的新东西我都必须链接在一起。我试图让这个简单的MySQL+PHP脚本工作,但是,我似乎得到了重复2次的结果 这是我的结果。 Array ( [0] => Matthew John [fullname] => Matthew John ) DB : Milky Table : userinfo id | fullname | username | email ---+--------------+----------
Array
(
[0] => Matthew John
[fullname] => Matthew John
)
DB : Milky
Table : userinfo
id | fullname | username | email
---+--------------+-------------+----------------------
1 | matthew john | matierpixel | matierpixel@gmail.com
$db = mysqli_connect("localhost", "root", "********", "milky");
$query = mysqli_query($db, "SELECT fullname FROM userinfo");
$result = mysqli_fetch_array($query);
print_r($result);
这是整个数据库及其一个表。
Array
(
[0] => Matthew John
[fullname] => Matthew John
)
DB : Milky
Table : userinfo
id | fullname | username | email
---+--------------+-------------+----------------------
1 | matthew john | matierpixel | matierpixel@gmail.com
$db = mysqli_connect("localhost", "root", "********", "milky");
$query = mysqli_query($db, "SELECT fullname FROM userinfo");
$result = mysqli_fetch_array($query);
print_r($result);
我使用的代码来自W3学校。
Array
(
[0] => Matthew John
[fullname] => Matthew John
)
DB : Milky
Table : userinfo
id | fullname | username | email
---+--------------+-------------+----------------------
1 | matthew john | matierpixel | matierpixel@gmail.com
$db = mysqli_connect("localhost", "root", "********", "milky");
$query = mysqli_query($db, "SELECT fullname FROM userinfo");
$result = mysqli_fetch_array($query);
print_r($result);
我不知道这是否有助于得到答案,但我使用的是一个nginx服务器,PHP链接为FastCGI
谢谢,
matierpixel因为您没有定义结果类型
mysqli_fetch_数组
可能会为您提供一个数字数组和关联数组。你可以使用mysqli\u fetch\u assoc只获取后者。Hah,我完全误解了OP所说的结果重复的意思。仅在10分钟内,你就回答了我的问题。这就是StackOverFlow非常棒的原因。