0

我的脚本有问题。我知道数据库有两行并且没有输出。我认为我没有为我的查询获取数据。也许我做错了什么。我试图输出内容。也许另一双眼睛会有所帮助?

<?php


$host = "blah. Com";
$database = "blah";
$user = "blah";
$password = "blah";

$con =mysqli_connect($host,$user,$password,$database);

if(!$con)
{
echo "Could not connect: " . $database;
}

$sql = "SELECT * FROM CreditCards";

$result = mysqli_query($con,$sql);

echo "<select name=\"word\">";


while($ary = mysql_fetch_array($result))
{
    echo "<option value=\"" . $ary[cc_id] . "\">" . $ary[type] . "-" . $ary[last_four] . "</option>";
}
echo "</select>";
mysqli_close($con);

?>

提前对格式表示抱歉。我在我的移动设备上...

4

1 回答 1

0

您是否尝试过mysqli_fetch_array而不是mysql_fetch_array在您的 while 循环中?

于 2013-07-19T02:02:55.660 回答