Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/11/2012, 11:07
josuecasu
 
Fecha de Ingreso: septiembre-2012
Ubicación: Barreiro
Mensajes: 48
Antigüedad: 11 años, 7 meses
Puntos: 0
Pregunta Ingreso de varias filas a la vez con php a mysql

hola amigos que tal como van.. tengo un pequeño problemita.. no puedo ingresar varias filas no logro que me guarde los datos que tengo lesdejo mi codigo para ver en que estoy fallando porfa...
Código PHP:
<html>
<title>Sistema de Inventario</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrap">
<div id="header">
<h1><center>SISTEMA DE CONTROL Y SEGUIMIENTO <br /><br /><br /> DE SUMINISTROS DE OFICINA</h1></center>
</div>  <br />
 <div id="top"> </div>
 <div id="content">

<br/>

<?php
session_start
();
                    include(
"conexion/conexion.php");    
                if (isset(
$_POST['codd']))
                {
                    
$cod=$_POST['codd'];
                    
$producto=$_POST['produ'];
                    
$x=$_POST['cant']; 
                    
$respo=$_POST['respon'];
                    
$xx=mysql_query("insert into detallepedido ('coddetalle','producto','cantidad','responsable') values('$cod','$producto','$x','$respo')"$con);
                    echo 
"<script>alert('Categoria Guardada...!!!')</script>";
                                                                                                                    }
?>
    <input type='submit' name="submit" value='Guardar pedidos'  /></a>
<center>
    
    <div id="derecha">
        <h1></h1>
    
        <div class='text-border'>
        <?php
            
            
if (isset($_GET['id']))
                
$id $_GET['id'];
            else
                
$id 1;
            
            if (isset(
$_GET['action']))
                
$action $_GET['action'];
            else
                
$action "empty";
    
    
            switch(
$action){
            
                case 
"add":
                    if(isset(
$_SESSION['carro'][$id]))
                        
$_SESSION['carro'][$id]++;
                    else
                        
$_SESSION['carro'][$id]=1;
                break;
                
                case 
"remove":
                    if(isset(
$_SESSION['carro'][$id]))
                    {
                        
$_SESSION['carro'][$id]--    ;
                        if(
$_SESSION['carro'][$id]==0)
                            unset(
$_SESSION['carro'][$id]);
                    }
                    
                break;
                case 
"removeProd":
                    if(isset(
$_SESSION['carro'][$id])){
                        unset(
$_SESSION['carro'][$id]);
                    }
                break;
                
                case 
"mostrar":
                    if(isset(
$_SESSION['carro'][$id])){
                        continue;
                    }
                break;
                
                case 
"empty":
                    unset(
$_SESSION['carro']);
                
                break;
                        
                
            }

                
            if(isset(
$_SESSION['carro'])){
             echo 
" <table border=0 cellspacing=5 cellpadding=5 width='700'>";
                
$totalcoste 0;
                
//Inicializamos el contador de productos seleccionados.
                
$xTotal 0;
                
                echo 
"<tr>";
                    echo 
"<td><b>Productos</td>";
                    echo 
"<td><b>Cantidad</td>";
                    echo
"<td><b>Responsable</td>";
                    echo 
"<td><b>Accion</td>";
                    echo 
"<td colspan=2><b>Stock</td>";
                echo 
"</tr>";
                echo 
"<tr><td colspan=5><hr></td></tr>";
    
                    foreach(
$_SESSION['carro'] as $id => $x){
                    
$resultado mysql_query("select idsuministros , nomsuministros, unidades FROM suministros WHERE idsuministros='$id'");
                    
$mifila mysql_fetch_array($resultado);
                    
$producto $mifila['nomsuministros'];
                    
//acortamos el nombre del producto a 40 caracteres
                    
$producto substr($producto,0,40);
                    
$precio $mifila['unidades'];
                    
//Coste por art�culo seg�n la cantidad elegida
                    
$coste $precio $x;
                    
//Coste total del carro
                    
$totalcoste $totalcoste $coste;
                    
//Contador del total de productos a�adidos al carro
                //    $Total = $Total + $x;
                    
?>
                    <tr>
                    <input type="hidden" name="codd"id="codd"  maxlength='10'/>
                    <td><select name="produ" size="1" id="produ">
                    <option > <?php echo "$producto" ;?> </option>
                    </select>
                    <td><select name="cant" size="1" id="cant">
                    <option > <?php echo "$x" ;?> </option>
                    </select>
                    <td><select name="respon" size="1" id="respon">
                    <option > <?php echo $_SESSION["user"] ;?></option>
                    </select>
                    <td >
                    
                
                    <?php
                    
echo"<a href='carro.php?id="$id ."&action=add'><img src='images/carrito/aumentar.png' stle='padding:0 0px 0 5px;' alt='Aumentar cantidad' /></a>";
                    if (
$x 1)
                        echo 
"<a href='carro.php?id="$id ."&action=remove'><img src='images/carrito/restar.png' alt='Reducir cantidad' ></a>";
                    else
                        echo 
"<a href='carro.php?id="$id ."&action=removeProd'><img src='images/carrito/eliminar.png' alt='Reducir cantidad' /></a></td>";
                    
                    echo 
"<td align='right'>  </td>";
                    echo 
"<td  style='margin-left:10px'>$coste Cant.";
                    echo 
"</tr>";
                }
                
?>
                <tr><td colspan='5'><hr></td></tr>
                <tr>
                
        </tr>
            
                <tr>
        <td align='right' colspan='5'>
                
                
            
                </td>
                
            </tr>
                <td>
                
<td> <font color='red' size='+1'>Firma del Encargado </td>
<td> <font color='red' size='+1'>Firma de Autorizacion</font></td>
</table>
                <?php
                
}
            else
                echo 
"";
    
        
?>        
        <table width="200" border="0">
  <tr>
    <td> <a href="productos.php"><div class="regresar"></td></A><font color='red'></font></div></div></td>
  </tr>
</table>

</BR>
        </div> <!-- Cierro text-border -->
    </div> <!-- Cierro derecha -->

<!------ para desactivar la tecla f5 en mozilla y ie. ----->
<head>
<script language="javascript">

document.onkeydown = function(){
if(window.event && window.event.keyCode == 116){
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 505){
return false;
}
}
</script></head>   

<script language="javascript">
document.onkeydown = function(e)
{
if(e)
document.onkeypress = function(){return true;}

var evt = e?e:event;
if(evt.keyCode==116)
{
if(e)
document.onkeypress = function(){return false;}
else
{
evt.keyCode = 0;
evt.returnValue = false;
}
}

</script>
<div class="articles"></div>
</div>
<div id="bottom"> </div>
</div>
<div style="clear: both;"> </div>
</div>
<div id="footer"> Sistema de Control y Seguimiento de Sumunistros &copy; 

</div>
de antemano gracias a los que me puedan ayudar