
25/10/2008, 11:00
|
| | Fecha de Ingreso: agosto-2008
Mensajes: 367
Antigüedad: 16 años, 7 meses Puntos: 5 | |
simple codigo de noticias buenas. les agradezco su ayuda con este codigo
es muy simple pero al mismo tiempo no puedo hacer que marche,
soy nuevo en php, y quiero agregar a mi pagina una seccion de noticias. que trabaja con una base de datos, las noticias deben ir rotando solas.
el problema lo tengo ahora que quiero tomar los daros de la base.. por favor les pido una mano
el codigo es el sigiente:
<html>
<head>
<script>
noticiero=new Array();
// Pon las noticias de la siguiente forma: new noticia(imagen, titulo,texto,enlace)
<?php
mysql_connect("localhost", "root", "root") or die("no conecta con mysql");
mysql_select_db("club") or die ("no conecta con base de datos");
$result = mysql_query("SELECT * FROM 'noticias'");
while ($fila = mysql_fetch_array($result));
noticiero[$fila] = (imagen,titulo,texto,enlace)
?>
//noticiero[0]=new noticia("imagen","titulo","texto","http://www.google.es");
//noticiero[1]=new noticia("imagen","titulo","texto","http://www.google.es");
//noticiero[2]=...
espera=2 //Segundos de espera
function noticia(imagen,titulo,texto,enlace){
this.imagen=imagen;
this.texto=texto;
this.titulo=titulo
this.enlace=enlace
}
function obj(x){
return document.getElementById(x);
}
function mostrar(a){
obj("imagen_noticia").src=noticiero[a].imagen;
obj("titulo_noticia").innerHTML=$fila[a].titulo;
obj("texto_noticia").innerHTML=noticiero[a].texto;
obj("enlace").href=noticiero[a].enlace
}
b=0;
function cambiar(){
b=(noticiero.length-1>b)?b+1:0;
mostrar(b);
}
setInterval("cambiar()",espera*1000);
</script>
<style>
#imagen_noticia{
float:left;
}
</style>
<title>Untitled</title>
</head>
<body onload="mostrar(0);">
<div id="cuadro">
<img src="" id="imagen_noticia" />
<h1 id="titulo_noticia"></h1>
<p id="texto_noticia"></p>
<a href="#" id="enlace">leer más</a>
</div>
</body>
</html>
// agradezco su ayuda lo antes posible.. esto es parte del codigo para la entrega final de la carrera muhas gracias |