PHP mysql查询出错

I have two of this codes:

if($result=mysql_query($select))
while($row=mysql_fetch_array($result))
{

I want mysqli of this codes

    $con=mysqli_connect("localhost","username","password","my_db");
    $sql="select * from table_name";
    if ($result=mysqli_query($con,$sql))
    {
        while ($row=mysqli_fetch_array($result))
        {

        }
    }

Please try this one