Return to Snippet

Revision: 1226
at September 26, 2006 07:47 by gdonald


Updated Code
function sqlResult( $query, $row=0, $field=0 )
{
  if( in_array( 'mysql', $GLOBALS[ 'loaded_extensions' ] ) )
  {
    return @mysql_result( $query, $row, $field );
  }
  elseif( in_array( 'mysqli', $GLOBALS[ 'loaded_extensions' ] ) )
  {
    if( mysqli_num_rows( $query ) )
    {
      $x = 0;

      while( $array = mysqli_fetch_array( $query, MYSQLI_NUM ) )
      {
        if( $row == $x++ )
        {
          return isset( $array[ $field ] )
            ? $array[ $field ]
            : '';
        }
      }
    }
  }
}

Revision: 1225
at September 26, 2006 07:44 by gdonald


Initial Code
function sqlResult( $query, $row=0, $field=0 )
{
if( in_array( 'mysql', $GLOBALS[ 'loaded_extensions' ] ) )
{
return @mysql_result( $query, $row, $field );
}
elseif( in_array( 'mysqli', $GLOBALS[ 'loaded_extensions' ] ) )
{
if( mysqli_num_rows( $query ) )
{
$x = 0;

while( $array = mysqli_fetch_array( $query, MYSQLI_NUM ) )
{
if( $row == $x++ )
{
return isset( $array[ $field ] )
? $array[ $field ]
: '';
}
}
}
}
}

Initial URL

                                

Initial Description

                                

Initial Title
php mysql/mysqli result

Initial Tags
mysql

Initial Language
PHP