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;
}
ajreal
47.4k11 gold badges98 silver badges119 bronze badges
asked Nov 27, 2010 at 13:20
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'].

answered Nov 27, 2010 at 13:23
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.