0

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;
}
2
  • I don't know. What does the query look like? Commented Nov 27, 2010 at 13:22
  • Are you sure that the query is valid? Try to insert echo $query and look at the result. Commented Nov 27, 2010 at 13:23

1 Answer 1

1

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'].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.