Ver Mensaje Individual
  #8 (permalink)  
Antiguo 27/01/2009, 11:01
Coplo
 
Fecha de Ingreso: octubre-2008
Mensajes: 155
Antigüedad: 15 años, 6 meses
Puntos: 1
Respuesta: Ayudenme con mi problema porfavor

Si, Gracias a todos por ayudarme especialmente a d-ART, pero no funciona como uviera querido que funcione.
Lo que yo queria era que en una tabla que se llama noticias se sustrallera las ultimas 4 noticias y que por el create temporary table `newnoticias` tuviera las ultimas 4 noticias y que por aleatoriamente se sustrallera una noticia de las ultimas 4 noticias y no pasa eso.
aqui dejo mi nuevo codigo:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


  <title>Noticias</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>

<?php
// primero se conecta a la base de datos:
require 'conexion.php';
// creamos la consulta SQL. Esta consulta muestra TODOS los registros de la tabla "users":
$sqltabla="create temporary table `newnoticias` (

  `ID` int(11) unsigned NOT NULL auto_increment,
  `title` varchar(255) NOT NULL default '',
  `alias` varchar(255) NOT NULL default '',
  `title_alias` varchar(255) NOT NULL default '',
  `introtext` mediumtext NOT NULL,
  `fulltext` mediumtext NOT NULL,
  `state` tinyint(3) NOT NULL default '0',
  `sectionid` int(11) unsigned NOT NULL default '0',
  `mask` int(11) unsigned NOT NULL default '0',
  `catid` int(11) unsigned NOT NULL default '0',
  `created` datetime NOT NULL default '0000-00-00 00:00:00',
  `created_by` int(11) unsigned NOT NULL default '0',
  `created_by_alias` varchar(255) NOT NULL default '',
  `modified` datetime NOT NULL default '0000-00-00 00:00:00',
  `modified_by` int(11) unsigned NOT NULL default '0',
  `checked_out` int(11) unsigned NOT NULL default '0',
  `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `publish_up` datetime NOT NULL default '0000-00-00 00:00:00',
  `publish_down` datetime NOT NULL default '0000-00-00 00:00:00',
  `images` text NOT NULL,
  `urls` text NOT NULL,
  `attribs` text NOT NULL,
  `version` int(11) unsigned NOT NULL default '1',
  `parentid` int(11) unsigned NOT NULL default '0',
  `ordering` int(11) NOT NULL default '0',
  `metakey` text NOT NULL,
  `metadesc` text NOT NULL,
  `access` int(11) unsigned NOT NULL default '0',
  `hits` int(11) unsigned NOT NULL default '0',
  `metadata` text NOT NULL,
  PRIMARY KEY  (`ID`),
  KEY `idx_section` (`sectionid`),
  KEY `idx_access` (`access`),
  KEY `idx_checkout` (`checked_out`),
  KEY `idx_state` (`state`),
  KEY `idx_catid` (`catid`),
  KEY `idx_createdby` (`created_by`)

)";
$consulta1 = "insert into newnoticias select * from noticias limit 4,4";
$consulta = "select * from newnoticias order by rand() limit 1";
// la ejecutamos
$result = mysql_query($consulta);
?>
<table border="1">
<tr>
<th>pagína de noticias</th>
</tr>
<?php
While ($reg = mysql_fetch_assoc($result)) {
// en cada iteracion el array $reg va a contener un nuevo registro que cumpla las condiciones; se accede a los datos usando el nombre del campo como indice
?>
<!--por cada iteracion se crea una fila nueva con los datos de los campos correspondientes-->
<tr>
<td><?php echo $reg['introtext'] ?></td>
</tr>
<?php
}
?>
</table>

</body>
</html>