php代码中的SQL查询

i'm writing a code where i've got a variable named "grandtotal" with a value and i wanna compae this value with the ones in my database and fetch the corresponding resuly that is under the column "Percentage" in the db. m providing the query for the db m using : table name is range and both the attributes are declared as varchar.

INSERT INTO `range` (`Range`, `Percentage`) VALUES
('D', '25'),
('C', '35'),
('B', '40'),
('A', '50');

the chunk of my code is:

if($grandtotal >= 70 && $grandtotal <= 79)
{
     $sql = ("SELECT Percentage FROM range WHERE Range='D'");
     if (!mysql_query($sql,$con))
        {
            die('Error: ' . mysql_error());
        }
     $result=mysql_query($sql);
     while($row = mysql_fetch_array($result, MYSQL_ASSOC))
     {
         $rate = $row['Percentage'];
     } 
}
elseif($grandtotal >= 80 && $grandtotal <= 89)
{

     $sql = ("SELECT Percentage FROM range WHERE Range='C'");
     if (!mysql_query($sql,$con))
            {
                die('Error: ' . mysql_error());
            }
     $result=mysql_query($sql);
     while($row = mysql_fetch_array($result, MYSQL_ASSOC))
     {
         $rate = $row['Percentage'];
     } 
}

elseif($grandtotal >= 90 && $grandtotal <= 95)
{

     $sql = ("SELECT Percentage FROM range WHERE Range='B'");
     if (!mysql_query($sql,$con))
            {
                die('Error: ' . mysql_error());
            }
     $result=mysql_query($sql);

     while($row = mysql_fetch_array($result, MYSQL_ASSOC))
     {
         $rate = $row['Percentage'];
     } 
}

elseif($grandtotal >= 96 && $grandtotal <= 100)
{

     $sql = ("SELECT Percentage FROM range WHERE Range='A'");
          if (!mysql_query($sql,$con))
          {
              die('Error: ' . mysql_error());
          }
     $result=mysql_query($sql);
     while($row = mysql_fetch_array($result, MYSQL_ASSOC))
     {
         $rate = $row['Percentage'];
     } 
}

i'm getting the following error:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'range WHERE Range='C'' at line 1

thank u.

RANGE is a reserved word and should be in backticks (http://dev.mysql.com/doc/refman/5.1/en/partitioning-range.html)

$sql = ("SELECT Percentage FROM `range` WHERE `Range`='D'");