Foros del Web » Programando para Internet » PHP »

recoger arrays

Estas en el tema de recoger arrays en el foro de PHP en Foros del Web. Hola a todos, mi problema es el siguiente, tengo un formulario de captura de n renglones, he creado una matriz, para hacer esto, peor no ...
  #1 (permalink)  
Antiguo 27/02/2005, 00:22
 
Fecha de Ingreso: abril-2003
Ubicación: Monterrey, Nuevo Leon Mex
Mensajes: 300
Antigüedad: 21 años
Puntos: 3
Comp Puedo Hacerle Ayudaaaa???????

Hola a todos, mi problema es el siguiente, tengo un formulario de captura de n renglones, he creado una matriz, para hacer esto, peor no se como al momento de capturar un renglon de esta matriz, al momento de capturar en el ultimo campo de la matriz, esta se refresque y me imprima el ultimo renglon, y me de oportunidad de capturar el siguiente y asi sucesivamente,

Agradecere la ayuda que me puedan brindar.

Saludos a todos
  #2 (permalink)  
Antiguo 27/02/2005, 00:23
 
Fecha de Ingreso: abril-2003
Ubicación: Monterrey, Nuevo Leon Mex
Mensajes: 300
Antigüedad: 21 años
Puntos: 3
se me olvido poner el codigo pero ahi les va

<?
include("../includes/conectar.i");
$a_cta = array ();
array_push($a_cta,$cta);
$a_scta = array ();
array_push($a_scta,$scta);
$a_sscta = array ();
array_push($a_sscta,$sscta);
$a_compro = array ();
array_push($a_compro,$compro);
$a_dsc = array ();
array_push($a_dsc,$dsc);
$a_dh= array ();
array_push($a_dh,$dh);
$a_imp = array ();
array_push($a_imp,$imp);
echo " <style type=\"text/css\">"
. " body {"
. " background-color: #E8E4D7;"
. " }"
. " .Estilo1 {"
. " font-family: Arial, Helvetica, sans-serif;"
. " font-weight: bold;"
. " font-size: 10pt;"
. " }"
. " .Estilo2 {font-family: Arial, Helvetica, sans-serif}"
. " -->"
. " </style>"
. " <table width=\"767\" cellspacing=\"1\" border=\"\">"
. " <tr>"
. " <th scope=\"col\"><img src=\"../images/logoconta.jpg\" width=\"227\" height=\"43\" align=\"left\"\"></th>"
. " </tr>"
. " </table>"
. "<div align=\"center\">"
. "<link rel=\"StyleSheet\" href=\"../style.css\" type=\"text/css\">"
. " <center><br>";
if($npol=='' or $fpol=='')
{
echo "<style type=\"text/css\">"
." <!--"
.".Estilo1 {"
."color: #0000FF;"
."font-weight: bold;"
."}"
."-->"
."</style>"
."<table width=\"250\" border=\"1\">"
." <form method=\"POST\" action=\"condia01.php?npol=$npol\">"
."<tr>"
." <td width=\"134\"><div align=\"center\">Numero de Poliza </div></td>"
." <td><input value=\"$npol\" name=\"npol\" type=\"text\" id=\"npol\" size=\"4\" maxlength=\"4\"></td>"
." </tr></form>"
." <form method=\"POST\" action=\"condia01.php?npol=$npol\">"
."<tr>"
." <td width=\"134\"><div align=\"center\">Fecha de Poliza</div></td>"
." <td><input value=\"$fpol\" name=\"fpol\" type=\"text\" id=\"fpol\" size=\"10\" maxlength=\"10\"></td>"
." </tr></form>"
."</div>"
." </table>";
}
else
{
echo "<table width=\"790\" border=\"0\">"
." <tr>"
." <td width=\"62\"><b>Poliza</b></td>"
." <td width=\"89\">$npol</td>"
." <td width=\"900\">&nbsp;</td>"
." <td width=\"84\"><b>Cargos</b></td>"
." <td width=\"88\">7546.00&nbsp;</td>"
."</tr>"
."<tr>"
." <td><b>Fecha</b></td>"
."<td>$fpol</td>"
."<td><div align=\"center\" class=\"Estilo1\">Captura de Polizas</div></td>"
."<td><b>Creditos</b></td>"
."<td>8465.00</td>"
."</tr>"
."</table>"
."<br>"
."<table width=\"100%\" border=\"1\">"
."<tr>"
."<td width=\"3%\"><div align=\"center\">Cuenta</div></td>"
."<td width=\"3%\"><div align=\"center\">S-Cuenta</div></td>"
."<td width=\"5%\"><div align=\"center\">Sub-S-Cta</div></td>"
."<td width=\"3%\"><div align=\"center\">Comprobante</div></td>"
."<td width=\"65%\"><div align=\"center\">Descripcion</div></td>"
."<td width=\"3%\"><div align=\"center\">D / H</div></td>"
."<td width=\"15%\"><div align=\"center\">Importe</div></td>"
."</tr>";

while($i == 10)
{
$i++;
echo "<tr>"
."<td>"
."<input value=\"$a_cta[$i]\" name=\"array_push($a_cta,$cta)\" type=\"text\" id=\"array_push($a_cta,$cta)\" size=\"4\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_scta[$i]\" name=\"array_push($a_scta,$scta)\" type=\"text\" id=\"array_push($a_scta,$scta)\" size=\"4\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_sscta[$i]\" name=\"array_push($a_sscta,$sscta)\" type=\"text\" id=\"ssc[$i]\" size=\"4\" maxlength=\"3\"></td><"
."<td>"
."<input value=\"$a_compro[$i]\" name=\"array_push($a_comp,$compro)\" type=\"text\" id=\"array_push($a_compro,$compro)\" size=\"4\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_dsc[$i]\" name=\"array_push($a_dsc,$dsc)\" type=\"text\" id=\"array_push($a_dsc,$dsc)\" size=\"70\" maxlength=\"70\"></td>"
."<td>"
."<input value=\"$a_dh[$i]\" name=\"array_push($a_dh,$dh)\" type=\"text\" id=\"array_push($a_dh,$dh)\" size=\"2\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_imp[$i]\" name=\"array_push($a_imp,$imp)\" type=\"text\" id=\"array_push($a_imp,$imp)\" size=\"11\" maxlength=\"11\"></td>"
."</tr>";
}
echo "</table>";


}
echo "$a_cta[0],$a_cta[1],$a_cta[2]";

?>
  #3 (permalink)  
Antiguo 27/02/2005, 03:20
Avatar de jam1138
/** @package Moderador */
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 9.368
Antigüedad: 19 años, 9 meses
Puntos: 102
Cita:
Iniciado por pahs5809
(...) he creado una matriz, para hacer esto, peor no se como al momento de capturar un renglon de esta matriz, al momento de capturar en el ultimo campo de la matriz (...)
Ya viste en php.net las Funciones de matrices?
Creo lo que andas buscando es current(), prev() y next()... copio y pego un ejemplo del mismo php.net
Código PHP:
<?php
$transport 
= array('foot''bike''car''plane');
$mode current($transport); // $mode = 'foot';
$mode next($transport);    // $mode = 'bike';
$mode current($transport); // $mode = 'bike';
$mode prev($transport);    // $mode = 'foot';
$mode end($transport);    // $mode = 'plane';
$mode current($transport); // $mode = 'plane';
?>
Espero sea lo que buscas. Que haya suerte!
__________________
٩(͡๏̯͡๏)۶
» Cómo hacer preguntas de manera inteligente «

"100 años después, la revolución no es con armas, es intelectual y digital"
  #4 (permalink)  
Antiguo 27/02/2005, 18:10
 
Fecha de Ingreso: abril-2003
Ubicación: Monterrey, Nuevo Leon Mex
Mensajes: 300
Antigüedad: 21 años
Puntos: 3
recoger arrays

Hola disculpen por volver a publicar el mismo problema, pero me urge saber si se puede hacer esto, lo que quiero es capturar una serie de datos que los tengo en 1 array y que estos al momento de recargar la misma pagina me vayan desplegando la informacion que ya se habia capturado , pongo el link y el script para que se den idea http://www.contamax.com/contab/progs/condia01.php

codigo:

<?php
include("../includes/conectar.i");

if($i==0)
{
function array_envia($a_cta)
{
$tmp = serialize($a_cta);
$tmp = urlencode($tmp);
return $tmp;
}
$a_cta = array();
array_push($a_cta,$cta);
$a_scta = array();
array_push($a_scta,$scta);
$a_sscta = array();
array_push($a_sscta,$sscta);
$a_compro = array();
array_push($a_compro,$compro);
$a_dsc = array();
array_push($a_dsc,$dsc);
$a_dh= array();
array_push($a_dh,$dh);
$a_imp = array();
array_push($a_imp,$imp);
}
else
{
function array_recibe($a_cta)
{
$tmp = stripslashes($a_cta);
$tmp = urldecode($tmp);
$tmp = unserialize($tmp);
return $tmp;
}
$a_cta=$_GET['array'];
}
echo " <style type=\"text/css\">"
. " body {"
. " background-color: #E8E4D7;"
. " }"
. " .Estilo1 {"
. " font-family: Arial, Helvetica, sans-serif;"
. " font-weight: bold;"
. " font-size: 10pt;"
. " }"
. " .Estilo2 {font-family: Arial, Helvetica, sans-serif}"
. " -->"
. " </style>"
. " <table width=\"767\" cellspacing=\"1\" border=\"\">"
. " <tr>"
. " <th scope=\"col\"><img src=\"../images/logoconta.jpg\" width=\"227\" height=\"43\" align=\"left\"\"></th>"
. " </tr>"
. " </table>"
. "<div align=\"center\">"
. "<link rel=\"StyleSheet\" href=\"../style.css\" type=\"text/css\">"
. " <center><br>";
if($npol=='' or $fpol=='')
{
echo "<style type=\"text/css\">"
." <!--"
.".Estilo1 {"
."color: #0000FF;"
."font-weight: bold;"
."}"
."-->"
."</style>"
."<table width=\"250\" border=\"1\">"
." <form method=\"POST\" action=\"condia01.php?npol=$npol\">"
."<tr>"
." <td width=\"134\"><div align=\"center\">Numero de Poliza </div></td>"
." <td><input value=\"$npol\" name=\"npol\" type=\"text\" id=\"npol\" size=\"4\" maxlength=\"4\"></td>"
." </tr></form>"
." <form method=\"POST\" action=\"condia01.php?npol=$npol\">"
."<tr>"
." <td width=\"134\"><div align=\"center\">Fecha de Poliza</div></td>"
." <td><input value=\"$fpol\" name=\"fpol\" type=\"text\" id=\"fpol\" size=\"10\" maxlength=\"10\"></td>"
." </tr></form>"
."</div>"
." </table>";
}
else
{
echo "<table width=\"780\" border=\"0\">"
." <tr>"
." <td width=\"62\"><b>Poliza</b></td>"
." <td width=\"89\">$npol</td>"
." <td width=\"900\">&nbsp;</td>"
." <td width=\"84\"><b>Cargos</b></td>"
." <td width=\"88\">7546.00&nbsp;</td>"
."</tr>"
."<tr>"
." <td><b>Fecha</b></td>"
."<td>$fpol</td>"
."<td><div align=\"center\" class=\"Estilo1\">Captura de Polizas</div></td>"
."<td><b>Creditos</b></td>"
."<td>8465.00</td>"
."</tr>"
."</table>"
."<br>"
."<table width=\"740\" border=\"1\">"
."<tr>"
."<td width=\"3%\"><div align=\"center\">Cuenta</div></td>"
."<td width=\"3%\"><div align=\"center\">S-Cuenta</div></td>"
."<td width=\"5%\"><div align=\"center\">Sub-S-Cta</div></td>"
."<td width=\"3%\"><div align=\"center\">Comprobante</div></td>"
."<td width=\"65%\"><div align=\"center\">Descripcion</div></td>"
."<td width=\"3%\"><div align=\"center\">D / H</div></td>"
."<td width=\"15%\"><div align=\"center\">Importe</div></td>"
."</tr>";
$i=0;
while($i < 9)
{
echo "<tr><form method=\"POST\" action=\"condia01.php?a_cta=$a_cta&a_sct=$a_sct&ss c=$a_ssc&a_dsc=$a_dsc&a_dh=$a_dh&a_imp=$a_imp&i=$i &npol=$npol&fpol=$fpol\">"
."<td>";
if($a_cta[$i]=='')
{
echo"<input value=\"$a_cta[$i]\" name=\"array_push($a_cta,$cta)\" type=\"text\" id=\"array_push($a_cta,$cta)\" size=\"4\" maxlength=\"3\"></td>";
}
else
{
echo $a_cta[$i];
}
echo "<td>"
."<input value=\"$a_scta[$i]\" name=\"array_push($a_scta,$scta)\" type=\"text\" id=\"array_push($a_scta,$scta)\" size=\"4\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_sscta[$i]\" name=\"array_push($a_sscta,$sscta)\" type=\"text\" id=\"ssc[$i]\" size=\"4\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_compro[$i]\" name=\"array_push($a_comp,$compro)\" type=\"text\" id=\"array_push($a_compro,$compro)\" size=\"4\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_dsc[$i]\" name=\"array_push($a_dsc,$dsc)\" type=\"text\" id=\"array_push($a_dsc,$dsc)\" size=\"70\" maxlength=\"70\"></td>"
."<td>"
."<input value=\"$a_dh[$i]\" name=\"array_push($a_dh,$dh)\" type=\"text\" id=\"array_push($a_dh,$dh)\" size=\"2\" maxlength=\"3\"></td>"
."<td>"
."<input value=\"$a_imp[$i]\" name=\"array_push($a_imp,$imp)\" type=\"text\" id=\"array_push($a_imp,$imp)\" size=\"11\" maxlength=\"11\"></td>"
;
$i++;
}
echo " <table width=\"100\" cellspacing=\"0\" border=\"\">"
. " <tr>";
echo" <input type=\"image\" src=\"../images/bot-aceptar-on.gif\" name=\"imp\"></td>"
."</tr></form></table>";

}
echo "</table>";



//echo "$a_cta[0],$a_cta[1],$a_cta[2]";

?>
<?
/*function array_recibe($url_array) {
$tmp = stripslashes($url_array);
$tmp = urldecode($tmp);
$tmp = unserialize($tmp);

return $tmp;
}


$array=$_GET['array'];
// el método de envio usado. (en el ejemplo un link genera un GET. En el formulario se usa POST podria ser GET tambien ...)

$array=array_recibe($array);

foreach ($array as $indice => $valor){
echo $indice." = ".$valor."<br>";
} */

/// fin de codigo


No esta afinado el codigo porque me pare por lo del envio de arrays

Gracias por la ayuda que me puedan brindar
  #5 (permalink)  
Antiguo 28/02/2005, 08:22
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Por el momento no se puede ver tu ejemplo en ese link:
"Bandwidth Limit Exceeded"


De todas formas .. lo que pretendes hacer .. creo que lo mejor sería propagar ese array en una sesión (www.php.net/session así no necesitas ni serializar el array ..) crear una rutina para gestionar el añadir o incluso eliminar un elemento de dicho array y otra para leer ese array y así generar tu formulario con sus valores pre-definidos (los que ya tenía tu array en sus elementos) y el nuevo item si es necesario .. en definitiva esto es como funciona un carrito de compra común ..

Un saludo,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:04.