为什么这个函数不返回任何行?
function select_mysql($tabel, $order, $volgorder, $statement) {
$iCount = 0;
$rows = array();
$query = 'SELECT * FROM ' . $tabel . ' ' . $statement .
' ORDER BY `' . $order . '` ' . $volgorder . '';
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
while ($property = mysql_fetch_field($result)) {
$rows[$iCount][$property->name] = $row[$property->name];
}
$iCount++;
}
return $rows;
}
最佳答案
不需要 mysql_fetch_field()
内部循环。 $row
将是一个关联数组,其中包含该行的所有字段。因此,如果该表中有字段 a
、b
、c
,那么您可以使用 $row[' 访问它们a']
、$row['b']
和 $row['c']
。
关于php - mysql php函数没有返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4291834/