
el array solo graba un registro
Publicado por mario (17 intervenciones) el 02/01/2014 00:08:46
hola amigos, podrian ayudarme y decirme el por que el ARRAY solo me guarda un registro, muchas gracias.
/********************************** ENVIO.PHP *********************/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
session_start();
$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "";
$bd_base = "ajax";
$con = mysql_connect($bd_host, $bd_usuario, $bd_password);
mysql_select_db($bd_base, $con);?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Enviar formulario sin recargar</title>
<script language="javascript" src="jquery-1.3.min.js"></script>
<script language="javascript">
$(document).ready(function() {
$().ajaxStart(function() {
$('#loading').show();
$('#result').hide();
}).ajaxStop(function() {
$('#loading').hide();
$('#result').fadeIn('slow');
});
$('#form, #fo3').submit(function() {
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
success: function(data) {
$('#result').html(data);
}
})
return false;
});
})
</script>
<style type="text/css">
<!--
body,td,th {
color: #333333;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
fieldset {
width:380px;
margin:auto;
}
#result {
float:right;
position:fixed;
width:280px;
padding:10px;
border:1px solid #bfcddb;
margin:auto;
margin-top:10px;
text-align:center;
}
-->
</style>
</head>
<body>
<div id="result"></div>
<?php
$sql="SELECT * FROM empleados";
$sacar=mysql_query($sql);
while ($row=mysql_fetch_array($sacar))
{
?>
<form method="post" action="envio.php" id="fo3" name="fo3" >
<fieldset>
<legend>Perfil</legend>
<ol>
<li><label>Nombres:</label><input type="text" size="30" name="fnombres" value="<?php echo $row['nombre'] ?>"/></li>
<li><label>Apellidos:</label><input type="text" size="30" name="fapellidos" value="<?php echo $row['apellido'] ?>"/></li>
<li><label>Correo:</label><input type="text" size="30" name="fweb" value="<?php echo $row['web'] ?>"/></li>
</ol>
<input type="submit" name="mysubmit" value="Enviar" />
</fieldset>
<!--</div>
-->
</form>
<?php }?>
</body>
</html>
/********************************** ENVIO.PHP *********************/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "";
$bd_base = "ajax";
$con = mysql_connect($bd_host, $bd_usuario, $bd_password);
mysql_select_db($bd_base, $con);
session_start();
$nombre=$_POST['fnombres'];
$apellido=$_POST['fapellidos'];
$web=$_POST['fweb'];
$mi_carrito[]=array('nombre'=>$nombre,'apellido'=>$apellido,'web'=>$web);
$contar=count($mi_carrito);
echo "la cantidad de registros en el array son: <b>".$contar."</b>";
?>
Valora esta pregunta


0