Osea Algo asi 
<?    $cnt=mysql_connect("localhost","root","mysql");
   mysql_select_db("data",$cnt);
   $nfila=mysql_query("select id_tarea from tareas",$cnt);
   while ($file=mysql_fetch_array($nfila))
   {
      $nultimo=$file['id_tarea'];
      } 
      echo "Posicion ".strpos($nultimo,"-")."
";
   if ($nultimo > 0) {
      $x=$x+1;
   } else {
      $x=1 ;
   }
   $codigo=$x;
   echo $codigo;
   
?>