Posted By

gdonald on 09/26/06


Tagged

mysql mysqli result


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


php mysql/mysqli result


 / Published in: PHP
 

  1. function sqlResult( $query, $row=0, $field=0 )
  2. {
  3. if( in_array( 'mysql', $GLOBALS[ 'loaded_extensions' ] ) )
  4. {
  5. return @mysql_result( $query, $row, $field );
  6. }
  7. elseif( in_array( 'mysqli', $GLOBALS[ 'loaded_extensions' ] ) )
  8. {
  9. if( mysqli_num_rows( $query ) )
  10. {
  11. $x = 0;
  12.  
  13. while( $array = mysqli_fetch_array( $query, MYSQLI_NUM ) )
  14. {
  15. if( $row == $x++ )
  16. {
  17. return isset( $array[ $field ] )
  18. ? $array[ $field ]
  19. : '';
  20. }
  21. }
  22. }
  23. }
  24. }

Report this snippet  

You need to login to post a comment.