Tema: Superglobals
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/01/2009, 06:35
kadet
 
Fecha de Ingreso: febrero-2008
Mensajes: 120
Antigüedad: 16 años, 2 meses
Puntos: 1
Superglobals

Bien, he estado buscando por el foro y mas o menos me queda claro, pero tengo una prefabricada con estas variables y me cuesta saber que variable precisa de una u otra superglobal ($_get, $_post, etc...)

Pego codigo por si alguien tiene alguna sugerencia. Se agradece.




<table cellpadding=5 cellspacing=5 border="0" class="contenido">



<?php



$arr_item=explode("|",$myshop);

if (!empty($additem)){
$item_id=$additem;
$item_jm=1;
if (!strstr($myshop,"$item_id:")){
$apartament_item="|".$item_id.":".$item_jm;
$myshop.=$apartament_item;

}
}


if (!empty($edit_jml)){
$item_id=$item_id;
$item_jm=$edit_jml;
for ($co=1; $co<count($arr_item); $co++){
if (strstr($arr_item[$co],"$item_id:")){
$olditem = "|".$arr_item[$co];
$newitem = "|".$item_id.":".$item_jm;
$apartament_item=str_replace($olditem,$newitem,$my shop);
$myshop=$apartament_item;

}
}
}

if (!empty($del_item)){
$item_id=$del_item;
for ($co=1; $co<count($arr_item); $co++){
if (strstr($arr_item[$co],"$item_id:")){
$olditem = "|".$arr_item[$co];
$newitem = "";
$apartament_item=str_replace($olditem,$newitem,$my shop);
$myshop=$apartament_item;

}
}
}






$arr_item=explode("|",$myshop);


$total=0;
$subtotal=0;
if (!empty($myshop)){
echo "<table border=0 cellspacing=1 cellpadding=4 class=contenido width=100%>";

echo "<tr><td colspan=5><br />Aquesta es la seva reserva. Si us plau, indiquin's els numero de nits i procedeixi a establir el periode.<br /><br /></td></tr>";

echo "<tr><td class=peti><b>Imatge</td><td class=peti><b>Apartament</td><td class=peti><b>Preu</td><td class=peti><b>Càlcul Preu/Nit</td><td class=peti><b>Subtotal(".$defcurr.")</td></tr>";
for ($co=1; $co<count($arr_item); $co++){
$item_picture="";
$item_title="";
$item_description="";
$item_price="";
$ro_shop=explode(":",$arr_item[$co]);
$rs_item=@mysql_query("select * from apartament_item where id='$ro_shop[0]'");
$ada_item=@mysql_num_rows($rs_item);
if ($ada_item>0){
$item_picture=@mysql_result($rs_item,0,"picture");
$item_title=@mysql_result($rs_item,0,"title");
$item_description=@mysql_result($rs_item,0,"descri ption");
$item_curr=@mysql_result($rs_item,0,"curr");
$item_price=@mysql_result($rs_item,0,"price");
$item_disc=@mysql_result($rs_item,0,"discount");
}
echo "<tr>";
echo "<td align=center valign=top width=1>";
if ( (!empty($item_picture)) and (file_exists($item_picture)) ){

echo "sin imagen";
} else{
$imgarr=@getimagesize($item_picture);
$winwidth=$imgarr[0]+40;
$winheight=$imgarr[1]+120;

echo "<img src='imatges_ap/".$item_picture."' alt=imagen border=0 width=100 /> ";



}
echo "</td>";
echo "<td><span class=titulardetalle>".$item_title."</span><br />";
echo "<br><span class=desc>".$item_description."</span>";
echo "<br /><br /><a href='detall.php?detail_id=".$ro_shop[0]."' class=black><img src=img/boton_detalle.png border=0 alt=ver detalle longdesc=ver detalle /></a>&nbsp;<a href='".$PHP_SELF."?del_item=".$ro_shop[0]."' class=black><img src=img/cancelar.png border=0 alt=cancelar longdesc=cancelar /></a>";
echo "</td>";
echo "<td align=right valign=top nowrap>";
if (!empty($item_disc)){
echo "<font color=#FF0000>".$item_curr." <strike>".number_format($item_price, 2)."</strike></font>";
echo "<br><font color=#008080>Desc: ".$item_disc."%</font>";
$item_price=$item_price - ($item_price*($item_disc/100));
echo "<br>".$item_curr." ".number_format($item_price, 2);
} else {
echo "<span class=preu>".number_format($item_price, 2)." ".$item_curr."</span>";
}

if ($defcurr<>$item_curr){
$curr_from=@mysql_result(@mysql_query("select curr_value from shop_curr where curr_name='$item_curr'"),0,0);
$curr_to=@mysql_result(@mysql_query("select curr_value from shop_curr where curr_name='$defcurr'"),0,0);
if ( (!empty($curr_from)) and (!empty($curr_to)) ){
$item_price=($item_price*$curr_to)/$curr_from;
echo "<br>(".$defcurr." ". number_format($item_price,2).")";
} else {

}
}








echo "</td>";
echo "<td align=right valign=top><select onChange=\"window.location = this.options[this.selectedIndex].value\" ";
echo ">";
for ($c=1;$c<=10;$c++){
echo "<option";
if ($c==$ro_shop[1]){ echo " selected"; }
echo " value='afegir_reserva.php?item_id=".$ro_shop[0]."&edit_jml=".$c."'>".$c."</option>";
}
echo "</select>";







echo "</td>";
$subtotal=$ro_shop[1]*$item_price;
echo "<td align=right valign=top class=preu>".number_format($subtotal, 2)."</td>";
echo "</tr>";
$total=$total+$subtotal;
}
echo "<tr><td class=peti colspan=4 align=right><b>T O T A L</td>";
echo "<td class=tota align=right><b>".number_format($total, 2)."</td></tr>";
echo "</table>";
echo "<div align=right><br>";
echo "<a href='apartaments.php' ><img src=img/tornar.png border=0 /></a>&nbsp; ";
echo "<input type='image' src=img/periodo.png name='btorder' value='Triar el periode' class=but onclick=window.location='ordenar.php'>&nbsp;&nbsp; ";
echo "<br /><br /></div>";
} else {
echo "<div align=center><h3><br>No tè cap reserva efectuada,<br><a href='apartaments.php' class=black>Visiteu els apartaments</a>...!</h3></div>";
}
?>