<?php
session_start
();
include(
"database_odbc.php");
include(
"func.php");
?>
<html><!-- #BeginTemplate "/Templates/template.dwt" -->
<head>
<!-- #BeginEditable "doctitle" --> 
<title>MusicWeb: Your Music. Your Way</title>
<!-- #EndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="641" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="640"> 
      <table width="640" border="0" cellspacing="0" cellpadding="2" bgcolor="#8080C0">
        <tr> 
          <td width="338"><img src="studio2/images/musicweblogo2.gif" width="316" height="83"></td>
          <td width="294" valign="top"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="3" height="80">
              <tr align="right" valign="top"> 
                <td> 
                  <p><font face="Tahoma,Arial,Helvetica" size="2"><b><?php print date("F d, Y"); ?><br>
                    </b></font></p>
                  <p>&nbsp;</p>
                  </td>
              </tr>
              <tr align="right" valign="bottom"> 
                <td height="30"> 
                  <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td align="right"><a href="viewcart.php"><img src="studio2/images/view.gif" width="55" height="16" border="0"></a></td>
                      <td><img src="studio2/images/numitems.gif" width="111" height="13"></td>
                      <td><?php include("counter.php"); ?></td>
                    </tr>
                  </table>
                  
                </td>
              </tr>
            </table>
            
          </td>
        </tr>
      </table>
      <table width="640" border="0" cellspacing="0" cellpadding="0">
        <tr bgcolor="#000000"> 
          <td width="11%"><img src="studio2/images/spcr_1x1.gif" width="1" height="1"></td>
          <td width="89%"><img src="studio2/images/spcr_1x1.gif" width="1" height="1"></td>
        </tr>
        <tr> 
          <td width="11%" bgcolor="#008000"> 
            <p bgcolor="#0000CC"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif"><img src="studio2/images/cdcdover1.jpg" width="71" height="71"></font></p>
          </td>
          <td width="89%" bgcolor="#008000">
            <table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" bgcolor="#0000CC"><i><font size="2">Enjoy 
                  deep discounts on hundreds of songs from up-and-coming stars. 
                  Build $7.99 or $9.99 CDs, click on SPECIAL when you see it. 
                  The <b>MusicWeb</b> Clearance Sale ends May 1, 2002 at 11:59 
                  p.m. so buy your bargains today!</font></i></font></td>
              </tr>
            </table>
            <font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" bgcolor="#0000CC"><i></i></font></td>
        </tr>
      </table>
      <table width="640" border="0" cellspacing="0" cellpadding="0">
        <tr bgcolor="#000000"> 
          <td width="125"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr> 
                <td><img src="studio2/images/explore.gif" width="70" height="23"></td>
              </tr>
            </table>
          </td>
          <td width="4">&nbsp;</td>
          <td background="studio2/images/dashes.gif" width="1"><img src="studio2/images/spcr_1x1.gif"></td>
          <td width="5">&nbsp;</td>
          <td width="505"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr> 
                <td> 
                  <div align="right"><img src="studio2/images/musicnews.gif" width="108" height="23"></div>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr> 
          <td width="125" valign="top" bgcolor="#CCCCCC"><?php toc(); ?></td>
          <td width="4" bgcolor="#CCCCCC">&nbsp;</td>
          <td background="studio2/images/dashes.gif" width="1"><img src="studio2/images/spcr_1x1.gif"></td>
          <td width="5" >&nbsp;</td>
          <td width="505" valign="top"> <!-- #BeginEditable "content" -->

<?php

# If the cart size is greater than zero then the ensuing code is processed.
# If not then it prints that the cart is empty.

if(getCartSize() > 0
{
    
# initialize a variable that will hold the total cost of items in the cart
    
$sum 0;
    
    
# Begin creating table to print cart contents.
     
    
print '&nbsp;<table border="1" cellspacing="0" cellpadding="2" width="95%"><tr>'.
        
'<th width="55%">Song Title</th>'.
        
'<th width="15%">$</th>'.
        
'<th width="10%">Qty</th>'.
        
'<th width="10%">Total</th>'.
        
'<th width="10%">DEL</th>'.
        
'</tr>';

    
# Iterate through items in the cart and print each item with its quantity and cost

    
while( list($k,$v)=each($cart) )  
    {
        
$sql 'SELECT SongTitle, SongPrice FROM Song '.
               
'WHERE SongTitle = \''.str_replace("_"," ",$v["ProductID"]).'\'';
                
        
$result db_query($sql); # Get result identifier to result set.
        
        # sum is equal to product of the cost of an item and the quantity of that item
        # for all items.  += is shorthand for adding the existing contents of the variable
        # sum to the amount to be added.
        
        
$sum += $v["Quantity"]*odbc_result($result,"SongPrice");
        
        print 
'<form method="POST" action="'.$REQUEST_URI.'"><tr><td align="center">'.
        
              
odbc_result($result,"SongTitle"). # get the title of the song from the result set
              
              
'</td><td align="center">'.
              
              
# format the price to two decimal places
              
number_format(odbc_result($result,"SongPrice"),2,".",",").
              
              
'</td><td align="center">'.$v["Quantity"].
              
'</td><td align="center">'.
              
# format the total for this item to two decimal places.
              
number_format(($v["Quantity"]*odbc_result($result,"SongPrice")),2,".",",").
              
'</td>'.
              
'<td align="center">'.
              
'<input type="hidden" name="ProductID" value="'.$v["ProductID"].'">'.
              
'<b><input type="submit" name="remove_from_cart" value=" X "></b></td></tr></form>';

    }

    print 
'<tr><td colspan="3" align="right">&nbsp;<b>Order Total</b>&nbsp;</td>'.
          
'<td align="center" bgcolor="#CCCCCC"><font size="4"><b>'.
          
          
# format total sum to two decimal places.
          
number_format($sum,2,".",","). 
          
          
'</b></font></td><td>&nbsp;</td></tr>';
    print 
'</table>'# Close the table.

    
print '<table border="0" cellspacing="0" cellpadding="0" width="95%">'.        
          
'<form method="POST" action="'.$REQUEST_URI.'"><tr><td align="right">'.
          
'<br><input type="submit" name="checkout" value="Checkout >>"></td></tr></form></table>';    
}else {
    print 
"<p>&nbsp;</p><h2>Your Shopping Cart is empty!</h2>";
}

?>

<!-- #EndEditable --> 
            <p>&nbsp;</p>
          </td>
        </tr>
      </table>
      <table width="640" border="0" cellspacing="0" cellpadding="5">
        <tr bgcolor="#008000"> 
          <td>&nbsp; </td>
        </tr>
        <tr> 
          <td> 
            <p><font size="2">&copy; MusicWeb, a Rensselaer Polytechnic Institute 
              Company.<br>
              MusicWeb and related marks are trademarks of Rensselaer Polytechnic 
              Institute. ALL RIGHTS RESERVED</font> </p>
          </td>
        </tr>
      </table>
    </td>
    <td background="studio2/images/dashes.gif" width="1"><img src="studio2/images/spcr_1x1.gif" width="1" height="1"></td>
  </tr>
  <tr>
    <td width="640" background="studio2/images/hdashes.gif"><img src="studio2/images/spcr_1x1.gif" width="1" height="1"></td>
    <td background="studio2/images/dashes.gif" width="1"><img src="studio2/images/spcr_1x1.gif" width="1" height="1"></td>
  </tr>
</table>
</body>
<!-- #EndTemplate --></html>