<?php
$servername = "localhost";
$serveruser = "username";
$password = "";
$connect =mysql_connect("$servername", "$serveruser", "$password");
mysql_select_db("dscbasketball") or die(mysql_error());
$result=mysql_query("SELECT * FROM players") or die(mysql_error());
$roll=mysql_fetch_array($result);
echo "Name: ".$roll['name'];
?>
这是我的代码,但我的输出就是这个 “姓名:Melissa”
我在'name'栏中有7个名字,为什么我只得到名字?
答案 0 :(得分:1)
试试这个
<?php
$servername = "localhost";
$serveruser = "username";
$password = "";
$connect =mysql_connect("$servername", "$serveruser", "$password");
mysql_select_db("dscbasketball") or die(mysql_error());
$result=mysql_query("SELECT * FROM players") or die(mysql_error());
while($roll=mysql_fetch_array($result)) // you have to use a loop to access all entries
{
echo "Name: ".$roll['name'];
}
?>