所以我正在为数据库设计一个 Web 界面,但是当我尝试从查询中打印值时,它们会以双精度形式出现,因为它们正在计算相同值的 2 个索引。有谁知道为什么会这样?
PHP代码:
function loadTable()
{
$name = $_GET["table"];
$db = new PDO("mysql:host=localhost;dbname=university", "root", "");
$query = "SELECT * FROM ".$name;
$rows = $db->query($query);
foreach ($rows as $row)
{
foreach ($row as $key => $value)
{
print ($key.":".$value."<br>");
}
}
}
这是我得到的输出:
FM_ID:1234
0:1234
LAST_NAME:
1:
FIRST_NAME:
2:
OFFICE:Bliss 200
3:Bliss 200
EXTENSION:4455
4:4455
HOME_PHONE:5726952
5:5726952
MOBILE_PHONE:71283509
6:71283509
ADDRESS:
7:
EMAIL:
8:
STARTING_YEAR:2011
9:2011
TERMINATION_YEAR:2014
10:2014
LATEST_DEGREE:CMPS
11:CMPS
OBTAINED_FROM:AUB
12:AUB
DEGREE_YEAR:2014
13:2014
RESEARCH_INTEREST:Robotics
14:Robotics