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` (
`idarticulo` int(11) NOT NULL,
`titulo` varchar(255) NOT NULL,
`texto` text NOT NULL,
`fuente` varchar(100) NOT NULL,
`img` varchar(100) default NULL,
`idboletin` int(11) NOT NULL,
`idtema` int(11) NOT 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` (
`idboletin` int(11) NOT NULL auto_increment,
`boletin` varchar(255) NOT NULL,
`fecha` varchar(50) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`idboletin`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Volcar la base de datos para la tabla `boletin`
--
INSERT INTO `boletin` VALUES (1, 'Boletin 1', 'Martes, 23 de Enero del 2007', '2007-01-23');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `tema`
--
CREATE TABLE `tema` (
`idtema` int(11) NOT NULL auto_increment,
`tema` varchar(100) NOT NULL,
PRIMARY KEY (`idtema`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Volcar la base de datos para la tabla `tema`
--
INSERT INTO `tema` VALUES (1, 'tecnologia');
INSERT INTO `tema` VALUES (2, 'talento');
INSERT INTO `tema` VALUES (3, 'productos');
--
-- Filtros para las tablas descargadas (dump)
--
--
-- Filtros para la tabla `articulos`
--
ALTER TABLE `articulos`
ADD CONSTRAINT `articulos_ibfk_1` FOREIGN KEY (`idboletin`) REFERENCES `boletin` (`idboletin`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `articulos_ibfk_2` FOREIGN 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($tema, 0);
$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