Extracting only numbers from data in mysql query
You can use the TRIM function, for example:

mysql&gt; SELECT TRIM(BOTH '_' FROM '_21_' );
21


So in your case, to remove all _ characters, you can use something like:

 $query = "SELECT Date, TRIM(BOTH '_' FROM Tenext) as Tenext FROM tbdata";