ORDER BY无法正常运行PHP和MYSQL

In my application I am using jquery sortable together with PHP and MySQL. This is working fine when I change an items position, it will update the position numbers in my database. enter image description here

The last row is the p_index column with the position numbers. So, this is working good. Well, the problem is when I select the results and try to order by p_index, it doesn't work.. Is there a problem with my query?

My selecting code is this:

function getSubChapters($column, $parentOrId, $type, $sort){

    $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    mysqli_set_charset($conn,CHARSET);

    $sql = "SELECT * FROM text WHERE $column=$parentOrId AND type=$type ORDER BY p_index ASC";
    $result = mysqli_query($conn, $sql);

    if (isset($sort)) {
        if ($sort == 1) {
            mysqli_close($conn);
            return $result;
        }
        if($sort = 2) {
            $chapter = mysqli_fetch_assoc($result);
            mysqli_close($conn);
            return $chapter;

        }
    }
}

And this is my request to the function

$chapters = getSubChapters('parent', $_GET['cat'], 1, 1);