Código :
<div id="noticias"> <script language="javascript"> function objetoAjax(){ var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } function MostrarConsulta(datos){ divResultado = document.getElementById('resultado'); ajax=objetoAjax(); ajax.open("GET", datos); ajax.onreadystatechange=function() { if (ajax.readyState==4) { divResultado.innerHTML = ajax.responseText } } ajax.send(null) } </script> <?php $sql = "SELECT n_id, n_fecha, n_cort, n_noticias, n_usuario, DATE_FORMAT(n_fecha, '%d/%m/%Y %H:%i:%s') as n_fecha FROM noti ORDER BY n_id DESC"; $rs = mysql_query($sql, $conect); // Leemos el contenido de la plantilla de temas $a = 0; $row = mysql_fetch_assoc($rs); while($row = mysql_fetch_assoc($rs)) { if($a < 15){ if($row['n_usuario'] != NULL ){ $foto = utf8_encode($row['n_usuario']); }else{ $foto = "imagen/nn.gif"; } echo" <div id=\"cuadroNoticias\">"; echo" <div class=\"cuadroNoticiasFoto\"><img src=\"$foto\" alt=\"\" width=\"97\" height=\"92\" border\"0\"/></div>"; echo" <div class=\"cuadroNoticiasTitulo\"><a href=\"foro_ver.php?n_id=".$row['n_id']."\">".utf8_encode($row['n_fecha'])."</a></div>"; echo" <div class=\"cuadroNoticiasTexto\">".utf8_encode($row['n_cort'])."</div>"; echo" </div>"; echo" <form name=\"consulta\" action=\"\" onsubmit=\"MostrarConsulta('consultaNoticias.php'); return false\">"; echo" <label>"; echo" <input type=\"submit\" value=\"Consultar\" />"; echo" </label>"; echo" </form>"; echo" <div id=\"resultado\"></div>"; $a++; } } ?> </div>