php mysql/mysqli result


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.