Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/08/2006, 10:33
Avatar de Chudux
Chudux
 
Fecha de Ingreso: marzo-2006
Mensajes: 247
Antigüedad: 18 años, 1 mes
Puntos: 3
Código PHP:
function display_cart($cart$change true$images 1)
{
  
// display items in shopping cart
  // optionally allow changes (true or false)
  // optionally include images (1 - yes, 0 - no)

  
global $items;
  global 
$total_price;

  echo 
"<table border = 0 width = 100% cellspacing = 0>
        <form action = show_cart.php method = post>
        <tr><th colspan = "
. (1+$images) ." bgcolor=\"#cccccc\">Item</th>
        <th bgcolor=\"#cccccc\">Price</th><th bgcolor=\"#cccccc\">Quantity</th>
        <th bgcolor=\"#cccccc\">Total</th></tr>"
;

  
//display each item as a table row
  
foreach ($cart as $isbn => $qty)
  {
    
$book get_book_details($isbn);
    echo 
"<tr>";
    if(
$images ==true)
    {
      echo 
"<td align = left>";
      if (
file_exists("images/$isbn.jpg"))
      {
         
$size GetImageSize("images/".$isbn.".jpg");
         if(
$size[0]>&& $size[1]>0)
         {
           echo 
"<img src=\"images/".$isbn.".jpg\" border=0 ";
           echo 
"width = "$size[0]/." height = " .$size[1]/">";
         }
      }
      else
         echo 
"&nbsp;";
      echo 
"</td>";
    }
    echo 
"<td align = left>";
    echo 
"<a href = \"show_book.php?isbn=".$isbn."\">".$book["title"]."</a> by ".$book["author"];
    echo 
"</td><td align = center>$".number_format($book["price"], 2);
    echo 
"</td><td align = center>";
    
// if we allow changes, quantities are in text boxes
    
if ($change == true)
      echo 
"<input type = text name = \"$isbn\" value = $qty size = 3>";
    else
      echo 
$qty;
    echo 
"</td><td align = center>$".number_format($book["price"]*$qty,2)."</td></tr>\n";
  }
  
// display total row
  
echo "<tr>
          <th colspan = "
. (2+$images) ." bgcolor=\"#cccccc\">&nbsp;</td>
          <th align = center bgcolor=\"#cccccc\">
              $items
          </th>
          <th align = center bgcolor=\"#cccccc\">
              \$"
.number_format($total_price2).
          
"</th>
        </tr>"
;
  
// display save change button
  
if($change == true)
  {
    echo 
"<tr>
            <td colspan = "
. (2+$images) .">&nbsp;</td>
            <td align = center>
              <input type = hidden name = save value = true>
              <input type = image src = \"images/save-changes.gif\"
                     border = 0 alt = \"Save Changes\">
            </td>
            <td>&nbsp;</td>
        </tr>"
;
  }
  echo 
"</form></table>";
}

//////////////////////////pagina que lo recibe show_cart.php//////////////
ademas manda un error con el foreach el cual localmente no sucede debe ser por las variables
 globales igual
y no se como arreglarlo por que en el codigo de arriba no entiendo esta linea
 
echo "<input type = text name = \"$isbn\" value = $qty size = 3>";
////////////////////////////////////////////////////
if($save)
  {
    foreach (
$cart as $isbn => $qty)
    {
      if($
$isbn=="0")
        unset(
$cart[$isbn]);
      else
        
$cart[$isbn] = $$isbn;
    }
    
$total_price calculate_price($cart);
    
$items calculate_items($cart);
  } 
ahi esta saludos

Última edición por Cluster; 03/08/2006 a las 10:56