Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>Documento sin ttulo</title>
</head>
<body>
<form id="form1" name="form1" method="post">
Nombre
<input name="nombre" type="text" id="textarea" value=""
size=45 />
<p>
Apellido
<input name="apellido" type="text" id="textarea2" value=""
size=45 />
</p>
<p>
Ocupacin
<input name="ocupacion" type="text" id="textarea3" value=""
size=45 />
</p>
<p>
Edad
<input name="edad" type="text" id="textarea4" value=""
size=45 />
</p>
<p>
Sexo
<input name="sexo" type="text" id="textarea5" value=""
size=45 />
<label>
<input type="submit" name="button" id="button" value="Guardar"
onclick="this.form.action = 'Insertar.php'" />
</label>
<label>
<input type="submit" name="button2" id="button2"
value="Mostrar" onclick="this.form.action = 'muestra.php'" />
</label>
</form>
</body>
</html>
"Nombre: $nombre.<br>";
"Apellido: $apellido.<br>";
"Ocupacion: $ocupacion.<br>";
"Edad: $edad.<br>";
"Sexo: $sexo.<br><br>";
<html>
<body>
<?php
//Conectarse y seleccionar base de datos
$link = mysql_connect('localhost', 'root');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
Ubicacion
Rack
Almacen-1
Almacen-2
Almacen-3
<body onload="limpiar()">
Bin
12.
<center>
13.
<h1><font color="green">Recepcion de
Equipo</font></h1>
14.
<hr />
15.
<form name="f_agregaequipo" method='post'
action="agregaequipo.php">
16.
17.
<table border="10">
18.
<tr>
19.
20.
</tr><tr>
21.
<td>Fabricante:</td>
22.
<td>
23.
<div id="fabricante">
24.
<select name="fabricante"
onchange="from(document.f_agregaequipo.fabricante.value,'pr
oducto','combproducto.php')">
25.
26.
27.
28.
asc";
29.
$res=mysql_query($sql,$con);
30.
31.
while ($reg=mysql_fetch_array($res))
32.
33.
?>
34.
<option value="<?php echo
$reg["cod_fabricante"];?>"><?php echo $reg["fabricante"];?
></option>
35.
36.
37.
38.
<?php
}
?>
</select>
39.
</div>
40.
</td>
41.
</tr><tr>
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
<td>Producto:</td>
<td>
<div id="producto">
<select name="producto">
<option selected disabled> </option>
</select>
</div>
</td>
</tr><tr>
52.
53.
54.
55.
56.
<td>Modelo:</td>
<td>
<div id="modelo">
<select name="modelo">
57.
58.
59.
60.
61.
62.
63.
64.
<td>Serial:</td>
<td>
65.
<input type="text" name="serial" size="30"
maxlength="30" />
66.
67.
</td>
</tr><tr>
68.
69.
70.
<td>Ubication:</td>
<td>
71.
<input type="text" name="ubicacion" size="30"
maxlength="30" />
72.
73.
</td>
</tr><tr>
74.
75.
76.
<td>Rack:</td>
<td>
77.
<input type="text" name="rack" size="30"
maxlength="30" />
78.
79.
</td>
</tr><tr>
80.
81.
82.
<td>Bin:</td>
<td>
83.
<input type="text" name="bin" size="30"
maxlength="30" />
84.
85.
</td>
</tr><tr>
86.
87.
88.
<td>Date:</td>
<td>
89.
<input Disabled name="fecha" value="<?php echo
date("m/d/Y H:i:s"); ?>" size="15" />
90.
91.
92.
</td>
</tr><tr>
93.
94.
95.
<td><input type ="reset" value = "reetablecer">
</td>
96.
97.
</tr>
98.
</table>
99.
100.
</form>
101.
</center>
102.
103.
</body>
104.
</html>
2.
3.
4.
$res=mysql_query($sql,$con);
5. ?>
6. <select name="producto"
onchange="from(document.f_agregaequipo.producto.value,'mo
delo','combmodelo.php')">
7.
8.
<?php
9.
while ($reg=mysql_fetch_array($res))
10.
11.
?>
12.
<option value="<?php echo $reg["cod_producto"];?
>"><?php echo $reg["producto"];?></option>
13.
<?php
14.
15.
?>
16.
</select>
include "conexion.php";
$sql="select * from t_modelo where cod_producto=".
$_GET["id"]."";
4.
$res=mysql_query($sql,$con);
5. ?>
6. <select name="modelo">
7. <option selected disabled> </option>
8.
<?php
9.
while ($reg=mysql_fetch_array($res))
10.
11.
?>
12.
<option value="<?php echo $reg["cod_modelo"];?
>"><?php echo $reg["modelo"];?></option>
13.
<?php
14.
15.
?>
16.
</select>
10.
11.
$insertar ="INSERT INTO t_agregaequipo VALUES
('$_POST[fabricante]','$_POST[producto]','$_POST[modelo
]','$_POST[serial]','$_POST[ubicacion]','$_POST[rack]','$_P
OST[bin]','$_POST[fecha]')";
12.
13.
14.
$resultado = mysql_query($insertar);
15.
16.
// Se cierra la conexin
17.
mysql_close();
18.
require('f_agregaequipo.php');
19.
?>
7. }
8. catch(err1)
9. {
10.
try
11.
12.
13.
14.
15.
16.
17.
try
18.
{
req = new ActiveXObject("Microsoft.XMLHTTP");
19.
20.
/* algunas versiones IE */
21.
22.
catch(err3)
{
23.
24.
req = false;
}
25.
26.
27.
28.
return req;
29.
30.
31.
//*********************************************************
******************************
32.
function from(id,ide,url){
33.
var
mi_aleatorio=parseInt(Math.random()*99999999);//para que no
guarde la pgina en el cach...
34.
35.
//alert(vinculo);
36.
miPeticion.open("GET",vinculo,true);//ponemos true
para que la peticin sea asincrnica
37.
miPeticion.onreadystatechange=miPeticion.onreadystatechang
e=function(){
38.
if (miPeticion.readyState==4)
39.
40.
//alert(miPeticion.readyState);
41.
if (miPeticion.status==200)
42.
43.
//alert(miPeticion.status);
44.
//var http=miPeticion.responseXML;
45.
var http=miPeticion.responseText;
46.
document.getElementById(ide).innerHTML= http;
47.
48.
49.
}/*else
50.
51.
document.getElementById(ide).innerHTML="<img
src='ima/loading.gif' title='cargando...' />";
52.
53.
}*/
54.
55.
miPeticion.send(null);
56.
57.
58.
//*********************************************************
***************************************
59.
function limpiar()
60.
61.
document.form.reset();
62.
63.
5. -- Servidor: localhost
6. -- Tiempo de generacin: 05-07-2013 a las 20:07:14
7. -- Versin del servidor: 5.5.31
8. -- Versin de PHP: 5.3.10-1ubuntu3.6
9.
10.
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
11.
12.
13.
14.
/*!40101 SET
@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT
*/;
15.
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESUL
TS */;
16.
/*!40101 SET
@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION
*/;
17.
18.
19.
--
20.
21.
--
22.
23.
-- --------------------------------------------------------
24.
25.
--
26.
27.
--
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
`fechaingreso` TIMESTAMP NOT NULL DEFAULT
CURRENT_TIMESTAMP,
38.
39.
40.
41.
--
42.
43.
--
44.
45.
INSERT INTO `t_agregaequipo` (`fabricante`, `producto`,
`modelo`, `serial`, `ubicacion`, `rack`, `bin`, `fechaingreso`)
VALUES
46.
('2', '6', '5', '31425526746', 'ALMACEN-1', 'A', 'A:2:1',
'0000-00-00 00:00:00'),
47.
('1', '2', '1', '545321122', 'ALMACEN-1', 'A', 'A:2:1', '000000-00 00:00:00'),
48.
('1', '1', '4', '6567854322345', 'ALMACEN-2', 'B', 'B:1:1',
'0000-00-00 00:00:00'),
49.
('3', '8', '10', '9876543433', 'ALMACEN-1', 'A', 'A:2:2',
'0000-00-00 00:00:00');
50.
51.
-- --------------------------------------------------------
52.
53.
--
54.
55.
--
56.
57.
58.
59.
60.
61.
) ENGINE=InnoDB DEFAULT CHARSET=latin1
AUTO_INCREMENT=8 ;
62.
63.
--
64.
65.
--
66.
67.
68.
(1, 'A:1:1'),
69.
(2, 'A:1:2'),
70.
(3, 'A:2:1'),
71.
(4, 'A:2:2'),
72.
(5, 'B:1:1'),
73.
(6, 'C:1:1'),
74.
(7, 'D:8:2');
75.
76.
-- --------------------------------------------------------
77.
78.
--
79.
80.
--
81.
82.
83.
`cod_fabricante` INT(11) NOT NULL
AUTO_INCREMENT,
84.
85.
86.
87.
) ENGINE=InnoDB DEFAULT CHARSET=latin1
AUTO_INCREMENT=4 ;
88.
89.
--
90.
91.
--
92.
93.
INSERT INTO `t_fabricante` (`cod_fabricante`,
`fabricante`) VALUES
94.
(1, 'DELL'),
95.
(2, 'HP'),
96.
(3, 'LEXMARK');
97.
98.
-- --------------------------------------------------------
99.
100.
--
101.
102.
--
103.
104.
105.
106.
107.
108.
109.
110.
) ENGINE=InnoDB DEFAULT CHARSET=latin1
AUTO_INCREMENT=14 ;
111.
112.
--
113.
114.
--
115.
116.
INSERT INTO `t_modelo` (`cod_modelo`, `modelo`,
`cod_producto`, `cod_fabricante`) VALUES
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
-- --------------------------------------------------------
131.
132.
--
133.
134.
--
135.
136.
137.
138.
139.
140.
141.
) ENGINE=InnoDB DEFAULT CHARSET=latin1
AUTO_INCREMENT=10 ;
142.
143.
--
144.
145.
--
146.
147.
INSERT INTO `t_producto` (`cod_producto`, `producto`,
`cod_fabricante`) VALUES
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
-- --------------------------------------------------------
158.
159.
--
160.
161.
--
162.
163.
164.
165.
166.
167.
) ENGINE=InnoDB DEFAULT CHARSET=latin1
AUTO_INCREMENT=5 ;
168.
169.
--
170.
171.
--
172.
173.
174.
(1, 'A'),
175.
(2, 'B'),
176.
(3, 'C'),
177.
(4, 'D');
178.
179.
-- --------------------------------------------------------
180.
181.
--
182.
183.
--
184.
185.
186.
`cod_ubicacion` INT(11) NOT NULL
AUTO_INCREMENT,
187.
188.
189.
) ENGINE=InnoDB DEFAULT CHARSET=latin1
AUTO_INCREMENT=3 ;
190.
191.
--
192.
193.
--
194.
195.
INSERT INTO `t_ubicacion` (`cod_ubicacion`,
`ubicacion`) VALUES
196.
(1, 'ALMACEN-1'),
197.
(2, 'ALMACEN-2');
198.
199.
/*!40101 SET
CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
200.
/*!40101 SET
CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS
*/;
201.
/*!40101 SET
COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Saludos a Todos ya pude resolver el acertijos aqui coloco el codigo
por si alguna persona lo necesita:
Solo sustituyan el codigo agregaequipo.php por este que les dejo a
continuacion:
Cdigo PHP
1. <?php
2. // Se establece la conexin con la fuente de datos
$cod_fabricante = $_POST[fabricante];
11.
$sql = "SELECT fabricante FROM t_fabricante WHERE
cod_fabricante = $cod_fabricante";
12.
$res1 = mysql_query($sql,$con);
13.
while ($reg=mysql_fetch_array($res1)){
14.
15.
$fabricante = $reg[fabricante];
}
16.
17.
// Utilizamos el codigo del Producto tomado del select y
los utilizamos para buscar el nombre del Producto.
18.
$cod_producto = $_POST[producto];
19.
$sql = "SELECT producto FROM t_producto WHERE
cod_producto = $cod_producto";
20.
$res2 = mysql_query($sql,$con);
21.
while ($reg=mysql_fetch_array($res2)){
22.
23.
24.
$producto = $reg[producto];
}
25.
// Utilizamos el codigo del Modelo tomado del select y los
utilizamos para buscar el nombre del Modelo.
26.
$cod_modelo = $_POST[modelo];
27.
$sql = "SELECT modelo FROM t_modelo WHERE
cod_modelo = $cod_modelo";
28.
$res3 = mysql_query($sql,$con);
29.
while ($reg=mysql_fetch_array($res3)){
30.
31.
$modelo = $reg[modelo];
}
32.
33.
$insertar ="INSERT INTO t_agregaequipo VALUES
('$fabricante','$producto','$modelo','$_POST[serial]','$_PO
ST[ubicacion]','$_POST[rack]','$_POST[bin]','$_POST[fecha
]')";
34.
35.
36.
37.
38.
$resultado = mysql_query($insertar);
39.
40.
// Se cierra la conexin
41.
mysql_close();
42.
require('f_agregaequipo.php');
43.
?>
Cdigo PHP
1.
2. $id_marca = $_POST["id_marca"]; //este lo obtines del
formulario
3.
4. $sql = "SELECT marca FROM marcas WHERE id_marca =
$id_marca"; //lo buscas para compararlo
5.
6. $nombre_marca = mysql_query(sql, conexion); // el resultado lo
guardas en una nueva variable
7.
8. // y a hora si lo insertas
9.
10. $insertar = "INSERT INTO registros VALUES ($nombre_marca,
$otro_dato, $etc);