Código PHP:
<?php
include("conectarse.php");
$link = conectarse();
$id = $_POST['variable'];
//echo($id);
//exit;
//$acierto = true;
$datos = array();
$noEncuentra = true;
if(!empty($id)){
//while($acierto){ //Tienes un while de más. Lo puedes manejar todo con uno
while($noEncuentra)
//echo("hola buvle while");
//exit;
$sql = "SELECT titulo FROM noticias WHERE id ='".$id."'";
$res = mysql_query($sql,$link);
if(mysql_num_rows($res) == 0){
echo("no hay consulta");
//exit;
$id++;
//$noEncuentra= false; //No hace falta, se mantiene el true original
}
else{
//echo($id);
//exit;
//$sql1 = "SELECT titulo FROM noticias WHERE id ='".$id."'";
//$r1 = mysql_query($sql1,$link); //Pq volver a hacer la consulta? ;)
$noticiaArr = mysql_fetch_array($res);
$noticia = $noticiaArr[0];
echo($noticia);
$noEncuentra = false; //Para salir del bucle!
}
//}
}
?>
Prueba así xD