我的 php 文件中有这个
$atr_info = "SELECT * from attributes";
$atr_info2 = mysql_query($atr_info) or die ("Couldn't get attributes");
$atr = mysql_fetch_array($atr_info2)or die ("Couldn't make array");
die ($atr['attribute'][n]);
属性表有 3 列:id、attribute、tooltip
并且有很多行。我希望能够返回列属性中行“n”的值,但它不起作用,它返回列的第一行,并显示该字段中的第 N 个字母,我该如何使其工作?
最佳答案
$i = 1;
$rows = array();
$atr_info2 = mysql_query("SELECT * from attributes") or die ("Couldn't get attributes");
while($row = mysql_fetch_array($atr_info2)) {
$rows[$i] = $row;
$i++;
}
现在您可以像这样访问第 45 行中的属性列:
echo $rows[45]['attribute'];
关于php - 如何从 "SELECT * FROM"mysql_fetch_array 查询访问数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6884553/