Foros del Web » Programando para Internet » PHP »

problema con cargar registros en formularios

Estas en el tema de problema con cargar registros en formularios en el foro de PHP en Foros del Web. Hola estimados resulta que tengo un formulario metido dentro de un php y en dicho formulario necesito cargar los datos y modificarlos, pero esto no ...
  #1 (permalink)  
Antiguo 30/04/2011, 02:12
Avatar de lagunillano  
Fecha de Ingreso: abril-2011
Ubicación: Santiago de Chile, Dominican Republic
Mensajes: 16
Antigüedad: 13 años
Puntos: 1
problema con cargar registros en formularios

Hola estimados resulta que tengo un formulario metido dentro de un php y en dicho formulario necesito cargar los datos y modificarlos, pero esto no me resulta ya que como el formulario esta dentro del php no me toma la sentencia.

ojala alguien de ustedes me pudiera ayudar

les dejo el codigo del formulario para que lo vean y un pantallaso del formulario.

PD: las variables viajan porque ya las probe pero lo que no hace es mostrarmelas en la caja de texto


CODIGO DEL FORMULARIO
Código PHP:
<?php
include 'cnx.php';
session_start();
$reg=$_SESSION["usuario"];

if (!isset (
$reg))
    
header("Location: buscar.php");


$perfilUsuario $reg->perfil;

/*****************************OBTENER LOS DATOS DEL USUARIO LOGUEADO*****************************************/

$sqlConsulta "SELECT * FROM usuarios WHERE perfil = '$perfilUsuario'";
$resultConsulta mysql_query($sqlConsulta);

$fila mysql_fetch_array($resultConsulta);

$idUsuario $fila["id_usr"];

/**************************************OBTENER LOS PERMISOS DEL USUARIOS LOGUEADO*****************************/

$sqlPermisos "SELECT * FROM permisos WHERE id_usuario = '$idUsuario'";

$resultPermisos mysql_query($sqlPermisos$conn);

while(
$MostrarPermisos mysql_fetch_array($resultPermisos))
{
       
//print_r($MostrarPermisos);
    
$nombre $MostrarPermisos["campo_nombre"];
    
$descripcion $MostrarPermisos["campo_descripcion"];
    
$codigo $MostrarPermisos["campo_codigo"];
    
$stock $MostrarPermisos["campo_stock"];
    
$precio $MostrarPermisos["campo_precio"];
}

/*********************************CONSULTA PARA MOSTRAR LOS DATOS******************************************/

$reproducto mysql_query("SELECT * FROM productos WHERE id_prod="$_REQUEST["cod"].";",$conn);
$filaproducto mysql_fetch_array($reproducto);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Ingresar</title>
    </head>
    <body>
       <?php
        
print ("Bienvenido(a) ".$reg->nom." ".$reg->ape." - ");
        
?>
         <a href="salir.php">Finalizar Sesion</a><br><hr>
         <h3>Ingresar Productos</h3>
         <?php
         $sql 
="INSERT INTO productos (nom_prod, descrip_prod, cod_bodega, stock, precio)
                        VALUES
                        ('$_POST[nombre_prod]', '$_POST[descrip_prod]', '$_POST[cod_bodega]', '$_POST[sto]', '$_POST[prec]')"
;

            
$res mysql_query($sql);

            
?>

             <!--Aqui empieza el formulario -->
            <?php
            
echo '<form method=POST action="">';
            echo 
'<table aling=center border=1>';
            echo 
'<tr>';
            if(
$nombre == and $nombre != 0)
            {
               ------->>>>>> 
AQUI ESTA LA EXPRESION echo '<td>Nom del Producto</td><td><input type=text name=nombre_prod value="<?php$filaproducto["id_cod"]?>"></td>';
            
            }
            else
            {
            
// muestra codigo en la consulta
                
echo '<td>Nom del Producto</td><td><input type=text name=nombre_prod disabled=disabled </td>';
            }

            echo 
'</tr>';
            echo 
'<tr>';
            if(
$descripcion == and $descripcion != 0)
            {
            echo 
'<td>Descrip Producto</td><td><input type=text name=descrip_prod></td>';
            }
            else
            {
               echo 
'<td>Descrip Producto</td><td><input type=text name=descrip_prod disabled=disabled></td>';
            }
            echo 
'</tr>';
            echo 
'<tr>';
            if(
$codigo == and $codigo != 0)
            {
                echo 
'<td>Cod de Producto</td><td><input type=text name=cod_bodega></td>';
            }
            else
            {
              echo 
'<td>Cod de Producto</td><td><input type=text name=cod_bodega disabled=disabled></td>';
            }
            echo 
'</tr>';
            echo 
'<tr>';
            if(
$stock == and $stock != 0)
            {
            echo 
'<td>Stock</td><td><input type=text name=sto></td>';
            }
            else
            {
             echo 
'<td>Stock</td><td><input type=text name=sto disabled=disabled></td>';
            }
            echo 
'</tr>';
            echo 
'<tr>';
            if(
$precio == and $precio != 0)
            {
            echo 
'<td>Precio $</td><td><input type=text name=prec></td>';
            }
            else
            {
              echo 
'<td>Precio $</td><td><input type=text name=prec disabled=disabled></td>';
            }
            echo 
'</tr>';
            echo 
'<tr>';
            echo 
'<td colspan="2"><input value="Grabar Producto" type="submit" name="subgrabar">';
            echo 
'</tr>';
            echo 
'</table>';
            echo 
'</form>';
           
// }
         
?>
    </body>
</html>



consulta de producto, desde aqui se redirije al formulario con los datos




Código PHP:
<?PHP
include ("cnx.php");
$resultado mysql_query("SELECT * FROM productos",$conn);
$registros mysql_num_rows($resultado);
if (
$registros==0)
{    
    echo 
"no se han encontrado registros";
    
mysql_close($conn);
    exit();
}

?>
<!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>Untitled Document</title>
</head>

<body>
<table width="835" border="1,5">
  <tr>
    <th width="85" scope="col">&nbsp;</th>
    <th width="67" scope="col">&nbsp;</th>
    <th width="117" scope="col">&nbsp;</th>
    <th width="113" scope="col">&nbsp;</th>
    <th width="65" scope="col">&nbsp;</th>
    <th width="63" scope="col">&nbsp;</th>
    <th width="109" scope="col">&nbsp;</th>
  </tr>

  <tr>
    <td>ID PRODUCTO</td>
    <td>NOMBRE</td>
    <td>DESCRIPCION</td>
    <td>COD. BODEGA</td>
    <td>STOCK </td>
    <td>PRECIO</td>
    <th width="109" scope="col">OPERACION</th>
  </tr>
    <?php
  
while ($filamysql_fetch_array($resultado))
     {
    
?>
  <tr>
    <td><?php echo $fila ["id_prod"];?></td>
    <td><?php echo $fila ["nom_prod"];?></td>
    <td><?php echo $fila ["descrip_prod"];?></td>
    <td><?php echo $fila ["cod_bodega"];?></td>
    <td><?php echo $fila ["stock"];?></td>
    <td><?php echo $fila ["precio"];?></td>
    <th width="109" scope="col"><a href="modificarProducto.php?cod=<?php echo $fila ["id_prod"];?>">Modificar</a></th>
    <?php
     
}
     
?>
  </tr>
</table>
</body>
</html>
desde ya muchas gracias

Etiquetas: formulario
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 01:01.