Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/01/2007, 09:35
Avatar de rogertm
rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 9 meses
Puntos: 638
Exclamación mostrar en un SELECT los datos de una tabla MySQL

hola a toda la peña, tengo una pequeña base de datos en MySQL, solo tres tablas, relacionadas entre si, y quiero, para hacer el adminisrtador y poder llenar la base de datos, que se me muestren los datos de una de las tablas en un SELECT en uno de los formularios de dicho administrador, ahora al detalle:
las tablas MySQL:
Código PHP:
-- Estructura de tabla para la tabla `articulos`
-- 

CREATE TABLE `articulos` (
  `
idarticuloint(11NOT NULL,
  `
titulovarchar(255NOT NULL,
  `
textotext NOT NULL,
  `
fuentevarchar(100NOT NULL,
  `
imgvarchar(100) default NULL,
  `
idboletinint(11NOT NULL,
  `
idtemaint(11NOT NULL,
  
PRIMARY KEY  (`idarticulo`),
  
KEY `idboletin` (`idboletin`),
  
KEY `idtema` (`idtema`)
ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- 
-- 
Volcar la base de datos para la tabla `articulos`
-- 


-- --------------------------------------------------------

-- 
-- 
Estructura de tabla para la tabla `boletin`
-- 

CREATE TABLE `boletin` (
  `
idboletinint(11NOT NULL auto_increment,
  `
boletinvarchar(255NOT NULL,
  `
fechavarchar(50NOT NULL,
  `
datedate NOT NULL,
  
PRIMARY KEY  (`idboletin`)
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

-- 
-- 
Volcar la base de datos para la tabla `boletin`
-- 

INSERT INTO `boletinVALUES (1'Boletin 1''Martes, 23 de Enero del 2007''2007-01-23');

-- --------------------------------------------------------

-- 
-- 
Estructura de tabla para la tabla `tema`
-- 

CREATE TABLE `tema` (
  `
idtemaint(11NOT NULL auto_increment,
  `
temavarchar(100NOT NULL,
  
PRIMARY KEY  (`idtema`)
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=;

-- 
-- 
Volcar la base de datos para la tabla `tema`
-- 

INSERT INTO `temaVALUES (1'tecnologia');
INSERT INTO `temaVALUES (2'talento');
INSERT INTO `temaVALUES (3'productos');

-- 
-- 
Filtros para las tablas descargadas (dump)
-- 

-- 
-- 
Filtros para la tabla `articulos`
-- 
ALTER TABLE `articulos`
  
ADD CONSTRAINT `articulos_ibfk_1FOREIGN KEY (`idboletin`) REFERENCES `boletin` (`idboletin`) ON DELETE CASCADE ON UPDATE CASCADE,
  
ADD CONSTRAINT `articulos_ibfk_2FOREIGN KEY (`idtema`) REFERENCES `tema` (`idtema`) ON DELETE CASCADE ON UPDATE CASCADE
ahora el codigo php que tengo en la pagina:
Código PHP:
<?php
mysql_select_db
($database$connection);
$query_mostrar_tema "SELECT * FROM tema";
$mostrar_tema mysql_query($query_mostrar_tema$connection) or die(mysql_error());
$row_mostrar_tema mysql_fetch_assoc($mostrar_tema);
$totalRows_mostrar_tema mysql_num_rows($mostrar_tema);
?>

//y aqui el formulario:

<select name="tema">
      <?php do { ?>
      <option value="<?php echo $row_mostrar_tema['idtema']?>"><?php echo $row_mostrar_tema['tema']?>
      </option>
      <?php
} while ($row_mostrar_tema mysql_fetch_assoc($tema));
  
$rows mysql_num_rows($tema);
  if(
$rows 0) {
      
mysql_data_seek($tema0);
      
$row_mostrar_tema mysql_fetch_assoc($tema);
  }
?>
     </select>
osea, tengo en otras paginas los formularios que me insertan la informacion en las tablas boletin y temas, y en esta pagina queiro que me recoja los datos de la tabla tema, para poder rellenar la tabla de articulos, se entiende?
bueno, muchas gracias de antemano, espero recibir, como siempre, la ayuda de ustedes.
saludos
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose