替代mysqli的odbc_result方法

A few days ago I have developed a PHP project with mssql server database. Right now I need to change the MSSQL database to MySQL database. Previously I have used the odbc_result method but I am converting the all methods of odbc to those of mysqli procedural. So I need a function that works like odbc_result for mysqli – which one is it? I am trying to use mysqli_result but it throws an error "Call to undefined function mysqli_result()". Below I have menthid the function:

function checkCountry($con)
{
if ($con != '') {

    $cCodeList = array();
    $i = 0;

    $checkCountrySql = "SELECT country_code FROM country";
    $checkCountyResult = mysqli_query($con, $checkCountrySql);
    while (mysqli_fetch_row($checkCountyResult)) {
        for ($j = 1; $j <= mysqli_num_fields($checkCountyResult); $j++) {
            $ar = mysqli_result($checkCountyResult, $j);
        }
        $cCodeList[$i] = $ar;
        $i++;
    }

    return $cCodeList;
    }
}

So what is the alternative of odbc_result for mysqli?

i am trying to use mysqli_result but it was throwing an error " Call to undefined function mysqli_result() ".

Because there's no mysqli_result() function available in MySQLi.

Now look at the for loop, you're overwriting $ar in each iteration of the loop. In fact, you don't need this for loop at all, simply change your while loop in the following way,

while ($row = mysqli_fetch_row($checkCountyResult)) {
    $cCodeList[] = $row;
}