Wouter van Reeven
Wouter van Reeven

Reputation: 545

mysql php function doesn't return value

Why doesn't this function do't return any row?

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

Upvotes: 0

Views: 263

Answers (1)

Marc B
Marc B

Reputation: 360572

There's no need for the mysql_fetch_field() inner loop. $row will be an associative array with all the row's field's in it. So if you've got fields a, b, c in that table, then you can access them with $row['a'], $row['b'], and $row['c'].

Upvotes: 1

Related Questions