$view = str_replace("#NO#",$no,$str); //$str中の#NO#を$noに変換して$viewに代入
$view = str_replace("#NAME#",$name,$str); //$str中の#NAME#を$nameに変換して$viewに代入
$view = str_replace("#MES#",$mes,$str); //$str中の#MES#を$mesに変換して$viewに代入

要するに1〜2行目の結果を3行目で上書きしちゃってるんだよw