简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM