Ver Mensaje Individual
  #10 (permalink)  
Antiguo 23/12/2008, 04:31
jonysi_d
 
Fecha de Ingreso: octubre-2007
Mensajes: 724
Antigüedad: 16 años, 6 meses
Puntos: 4
Respuesta: Coger variable de un select no vinculado a base de datos.???

te pongo la del carrito, imagino es donde hay el problema.
Este es el codigo de la conexion:

<?php
session_start();
if(isset($_SESSION['carrito']) || isset($_POST['lugar'])){
if(isset($_SESSION['carrito'])){
$carrito_mio=$_SESSION['carrito'];
if(isset($_POST['lugar'])){
$lugar=$_POST['lugar'];
$precio=$_POST['precio'];
$cantidad=$_POST['cantidad'];
$donde=-1;
for($i=0;$i<=count($carrito_mio)-1;$i ++){
if($lugar==$carrito_mio[$i]['lugar']){
$donde=$i;
}
}
if($donde != -1){
$cuanto=$carrito_mio[$donde]['cantidad'] + $cantidad;
$carrito_mio[$donde]=array("lugar"=>$lugar,"precio"=>$precio,"cantidad "=>$cuanto);
}else{
$carrito_mio[]=array("lugar"=>$lugar,"precio"=>$precio,"cantidad "=>$cantidad);
}
}
}else{
$lugar=$_POST['lugar'];
$precio=$_POST['precio'];
$cantidad=$_POST['cantidad'];
$carrito_mio[]=array("lugar"=>$lugar,"precio"=>$precio,"cantidad "=>$cantidad);
}
if(isset($_POST['cantidad2'])){
$id=$_POST['id'];
$cuantos=$_POST['cantidad2'];
if($cuantos<1){
$carrito_mio[$id]=NULL;
}else{
$carrito_mio[$id]['cantidad']=$cuantos;
}
}
if(isset($_POST['id2'])){
$id=$_POST['id2'];
$carrito_mio[$id]=NULL;

}


$_SESSION['carrito']=$carrito_mio;

}


?>

<?php
$tuseleccion = $_POST['select'];

?>

es la tabla donde imprime los resultados del carrito:

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="2%" align="left" valign="top" bgcolor="#CC0000"><strong><img src="imagenes/sup-izq.gif" width="11" height="11" /></strong></td>
<td width="44%" align="left" valign="top" bgcolor="#CC0000"><div align="center"><strong>Nombre del producto </strong></div></td>
<td width="12%" align="right" bgcolor="#CC0000"><strong>precio</strong></td>
<td width="16%" align="center" bgcolor="#CC0000"><strong>cantidad</strong></td>
<td width="12%" align="right" bgcolor="#CC0000"><strong>total</strong></td>
<td width="14%" align="right" valign="top" bgcolor="#CC0000"><img src="imagenes/sup-der.gif" width="11" height="11" /></td>
</tr>
<?php
if(isset($_SESSION['carrito'])){
$total=0;
for($i=0;$i<=count($carrito_mio)-1;$i ++){
if($carrito_mio[$i]!=NULL){
?>

<tr>
<td valign="top" bgcolor="#E6EAED"><?php print $carrito_mio[$i]['lugar']; ?></td>
<td valign="top" bgcolor="#E6EAED"><?php
$tuseleccion = $_POST['select'];
echo $tuseleccion;
?>

</td>
<td align="right" valign="top" bgcolor="#E6EAED"><?php print $carrito_mio[$i]['precio']; ?></td>
<td align="center" valign="top" bgcolor="#E6EAED">
<form id="form1" name="form1" method="post" action="">
<input name="id" type="hidden" id="id" value="<?php print $i; ?>" />
<input name="cantidad2" type="text" id="cantidad2" value="<?php print $carrito_mio[$i]['cantidad']; ?>" size="2" />
<input name="imageField" type="image" src="imagenes/actualizar.gif" alt="actualizar cantida" />
</form> </td>
<td align="right" valign="top" bgcolor="#E6EAED"><?php print $carrito_mio[$i]['precio'] * $carrito_mio[$i]['cantidad']; ?></td>
<td align="right" valign="top" bgcolor="#E6EAED"><form id="form2" name="form2" method="post" action="">
<input name="id2" type="hidden" id="id2" value="<?php print $i; ?>" />
<input name="imageField2" type="image" src="imagenes/papelera.gif" alt="borrar" />
</form> </td>
</tr>
<tr>
<td colspan="6" valign="top" bgcolor="#E6EAED"><hr /></td>
</tr>

<?php
$total=$total + ($carrito_mio[$i]['precio'] * $carrito_mio[$i]['cantidad']);
}
}
}
?>
<tr>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td align="right">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
<td>Subtotal<strong> :</strong></td>
<td align="right"><?php
if(isset($_SESSION['carrito'])){
print $total;
}
?></td>
<td align="right">
<div align="right">Euros &quot;&euro;&quot; </div></td></tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
<td>+ (16% IVA )</td>
<td align="right"><?php
if(isset($_SESSION['carrito'])){
$por=$total*16;
$div=$por/100;
$totaliva=$div;
print $totaliva;
}
?></td>
<td align="right">Euros &quot;&euro;&quot;</td>
</tr>
<tr>
<td height="19" colspan="2">&nbsp;</td>
<td><strong>TOTAL =</strong></td>
<td colspan="2"><div align="right">
<?php
if(isset($_SESSION['carrito'])){
$iva=$total*1.16;
print " <span style=\"font-size:20pt;font-weight:bold;\">". $iva. "</span>";
}
?>

</div></td>
<td align="left"><div align="right">Euros &quot;&euro;&quot;</div></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
<td colspan="3"><form id="form3" name="form3" method="post" action="supedido.php">
<input type="submit" name="Submit" value="Comprovar pedido" />
</form> </td>
</tr>
</table>

Última edición por jonysi_d; 23/12/2008 a las 05:36