2010-11-27 104 views
0

爲什麼這個函數不返回任何行?mysql php函數不返回值

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; 
} 
+0

我不知道。查詢是什麼樣的? – deceze 2010-11-27 13:22:46

回答

1

不需要mysql_fetch_field()內循環。 $row將是一個關聯數組,其中包含所有行的字段。因此,如果您在該表中有a,b,c字段,則可以使用$row['a'],$row['b']$row['c']訪問它們。