Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Esmksk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 6 additions & 0 deletions bootstrap.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions bootstrap.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions ciudad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
$conexion = new mysqli("localhost", "root", "", "ejercicio2");

if ($conexion->connect_error) {
die("Conexión fallida: " . $conexion->connect_error);
}

if(isset($_POST['id_departamento'])) {
$id_departamento = $_POST['id_departamento'];
$sql = "SELECT * FROM ciudad WHERE id_departamento = ?";
$stmt = $conexion->prepare($sql);
$stmt->bind_param("i", $id_departamento);
$stmt->execute();
$resultado = $stmt->get_result();

echo '<option value="">Selecciona una ciudad</option>';
while ($fila = $resultado->fetch_assoc()) {
echo '<option value="'.$fila['id_ciudad'].'">'.$fila['ciudad'].'</option>';
}

$stmt->close();
}

$conexion->close();
?>
25 changes: 25 additions & 0 deletions departamento.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
$conexion = new mysqli("localhost", "root", "", "ejercicio2");

if ($conexion->connect_error) {
die("Conexión fallida: " . $conexion->connect_error);
}

if(isset($_POST['id_pais'])) {
$id_pais = $_POST['id_pais'];
$sql = "SELECT * FROM departamento WHERE id_pais = ?";
$stmt = $conexion->prepare($sql);
$stmt->bind_param("i", $id_pais);
$stmt->execute();
$resultado = $stmt->get_result();

echo '<option value="">Selecciona un departamento</option>';
while ($fila = $resultado->fetch_assoc()) {
echo '<option value="'.$fila['id_departamento'].'">'.$fila['departamento'].'</option>';
}

$stmt->close();
}

$conexion->close();
?>
156 changes: 156 additions & 0 deletions ejercicio2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Servidor: localhost
-- Tiempo de generación: 08-11-2024 a las 21:03:00
-- Versión del servidor: 5.7.34
-- Versión de PHP: 8.2.6

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de datos: `ejercicio2`
--

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

--
-- Estructura de tabla para la tabla `ciudad`
--

CREATE TABLE `ciudad` (
`id_ciudad` int(11) NOT NULL,
`ciudad` varchar(200) NOT NULL,
`id_departamento` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Volcado de datos para la tabla `ciudad`
--

INSERT INTO `ciudad` (`id_ciudad`, `ciudad`, `id_departamento`) VALUES
(1, 'Sincelejo', 1),
(2, 'Coveñas', 1),
(3, 'Lorica', 2),
(4, 'Momil', 2),
(5, 'São Paulo', 3),
(6, 'Guarulhos', 3),
(7, 'Rio de Janeiro', 4),
(8, 'Niterói', 4);

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

--
-- Estructura de tabla para la tabla `departamento`
--

CREATE TABLE `departamento` (
`id_departamento` int(11) NOT NULL,
`departamento` varchar(200) NOT NULL,
`id_pais` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Volcado de datos para la tabla `departamento`
--

INSERT INTO `departamento` (`id_departamento`, `departamento`, `id_pais`) VALUES
(1, 'Sucre', 1),
(2, 'Cordoba', 1),
(3, 'São Paulo', 2),
(4, 'Rio de Janeiro', 2);

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

--
-- Estructura de tabla para la tabla `pais`
--

CREATE TABLE `pais` (
`id_pais` int(11) NOT NULL,
`pais` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Volcado de datos para la tabla `pais`
--

INSERT INTO `pais` (`id_pais`, `pais`) VALUES
(1, 'Colombia'),
(2, 'Brasil');

--
-- Índices para tablas volcadas
--

--
-- Indices de la tabla `ciudad`
--
ALTER TABLE `ciudad`
ADD PRIMARY KEY (`id_ciudad`),
ADD KEY `id_departamento` (`id_departamento`);

--
-- Indices de la tabla `departamento`
--
ALTER TABLE `departamento`
ADD PRIMARY KEY (`id_departamento`),
ADD KEY `id_pais` (`id_pais`);

--
-- Indices de la tabla `pais`
--
ALTER TABLE `pais`
ADD PRIMARY KEY (`id_pais`);

--
-- AUTO_INCREMENT de las tablas volcadas
--

--
-- AUTO_INCREMENT de la tabla `ciudad`
--
ALTER TABLE `ciudad`
MODIFY `id_ciudad` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT de la tabla `departamento`
--
ALTER TABLE `departamento`
MODIFY `id_departamento` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT de la tabla `pais`
--
ALTER TABLE `pais`
MODIFY `id_pais` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `ciudad`
--
ALTER TABLE `ciudad`
ADD CONSTRAINT `ciudad_ibfk_1` FOREIGN KEY (`id_departamento`) REFERENCES `departamento` (`id_departamento`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Filtros para la tabla `departamento`
--
ALTER TABLE `departamento`
ADD CONSTRAINT `departamento_ibfk_1` FOREIGN KEY (`id_pais`) REFERENCES `pais` (`id_pais`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
60 changes: 60 additions & 0 deletions estilo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
body {
font-family: Arial, sans-serif;
background-color: #f0f4f8;
color: #333;
margin: 0;
padding: 0;
}

.container {
max-width: 600px;
margin: 50px auto;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
padding: 20px;
}

h1 {
font-size: 28px;
color: #333;
text-align: center;
margin-bottom: 10px;
}

h2 {
font-size: 24px;
color: #ffffff;
background: linear-gradient(to bottom, #B9F2FF, #C5CAE9);
padding: 15px;
border-radius: 20px;
text-align: center;
margin-bottom: 30px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

label {
font-weight: bold;
color: #555;
display: block;
margin-bottom: 5px;
}

.form-select {
width: 100%;
padding: 10px;
font-size: 16px;
border: none;
border-radius: 5px;
background-color: #fafafa;
transition: background-color 0.3s ease;
}

.form-select:focus {
outline: none;
background-color: #e6f0ff;
}

.mb-3 {
margin-bottom: 20px;
}
Loading