mysqli_fetch_array()不起作用?

时间:2015-04-01 17:06:58

标签: php database

我有以下代码:



<?php
$link = mysqli_connect( 'localhost', 'root', '', 'pruebatiendas');
mysqli_error($link); 
$que = "select * from categoria";
$result = mysqli_query($link,$que) or die(mysqli_error($link));
?>
<!DOCTYPE html>
<html lang="es-co">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>imagenes</title>
</head>
<body>
<?php while($row=mysqli_fetch_array($result)) { ?>
<a href="prueba.html"><?php echo $row['nombre_c']?></a><br/>
<?php } ?>
</body>
</html>
&#13;
&#13;
&#13;

但没有告诉我链接,可能是什么错误?

1 个答案:

答案 0 :(得分:0)

如果我理解正确,那就是你需要的:

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("pruebatiendas") or die(mysql_error());


$query = mysql_query("SELECT * FROM categoria") 
or die(mysql_error());



<?php

while($row = mysql_fetch_array($query)) {
echo "<a href='prueba.html'>".$row['nombre_c']."</a><br />";
}
?>