CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> General/Other

 cc2.0.5 - php - mysql - Insert cart items to table order, items field

Print topic Send  topic

Author Message
epmedia

Posts: 4
Posted: 12/08/2004, 6:29 PM

All fields get inserted fine (cookieId, order_date), except for the cart_items which comes from a custom function which works fine for displaying the shopping cart items on web page.
cart_items = is an html table showing an id, name, qty, price, etc.

********custom cart function**********

  
function CartItems()  
{  
global $dbServer, $dbUser, $dbPass, $dbName;  
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);  
$fldzipId = $_COOKIE["zipId"];  
$fldstateId = $_COOKIE["stateId"];  
$Get_Tax_Rate = get_db_value("SELECT tax_rate FROM lookup_states WHERE state_id=" . tosql($fldstateId, "Text"));  
$Get_Ship_Rate = get_db_value("SELECT zip_shipr FROM zip_zone WHERE '" . GetZipId() . "' BETWEEN zip_start and zip_end");  
$totalCost = 0;  
$totalShip = 0;  
$result = mysql_query("select * from cart inner join items on cart.item_id = items.item_id where cart.cookieId = '" . GetCartId() . "' order by items.name_1 asc");  
?>  
  
<table border=1 cellpadding=4 cellspacing=0>  
  <tr>  
    <td>QTY</td>  
    <td>PART#</td>  
    <td>NAME</td>  
    <td>EACH</td>  
  </tr>  
<?  
while($row = mysql_fetch_array($result))  
{  
$totalCost += ($row["qty"] * $row["price"]);  
$totalShip += ($row["qty"] * $row["ship"]);  
$Gr_TotalShip = number_format($totalShip * $Get_Ship_Rate, 2, ".", ",");  
$Gr_TotalTax = number_format($totalCost * $Get_Tax_Rate, 2, ".", ",");  
?>  
  <tr>  
    <td><?php echo $row["qty"]; ?></td>  
    <td><?php echo $row["manuf_num"]; ?></td>  
    <td><?php echo $row["name_1"]; ?></td>  
    <td>$<?php echo number_format($row["price"], 2, ".", ","); ?></td>  
  </tr>  
<?php  
}  
$do_subtotal = number_format($totalCost, 2, '.', '');  
$do_subship = number_format($totalShip, 2, '.', '');  
?>  
  <tr>  
    <td colspan=2 align=right>Sub Total</td>  
    <td colspan=2>$ <?php echo number_format($totalCost, 2, ".", ","); ?></td>  
  </tr>  
  <tr>  
    <td colspan=2 align=right>Tax</td>  
    <td colspan=2>$ <?php echo number_format($totalCost * $Get_Tax_Rate, 2, ".", ","); ?></td>  
  </tr>  
  <tr>  
    <td colspan=2 align=right>Shipping</td>  
    <td colspan=2>$ <?php echo number_format($Gr_TotalShip, 2, ".", ","); ?></td>  
  </tr>  
  <tr>  
    <td colspan=2 align=right>Grand Total</td>  
    <td colspan=2>$ <?php echo number_format($totalCost + $Gr_TotalShip + $Gr_TotalTax, 2, ".", ","); ?></td>  
  </tr>  
</table>  
<?  
}  

********custom insert**********

  
$db->query("insert into orders(cookieId, cart_items, order_date, order_status) values('" . GetCartId() . "', '" . CartItems() . "', '" . date("F j, Y, g:i a") . "')");  

**********my notes************

in the insert I have tried tosql($fld-----, "Text") and a few more ways, including "insert delayed". If I make a $field-- = "the carts html code here"; and replace the cartitems function in the insert acordingly - that works fine. There are no errors displayed.

any help GREATLY appreciated!
Robert
View profile  Send private message
epmedia

Posts: 4
Posted: 12/08/2004, 7:05 PM

Authors notes:
I made a mistake on the insert code when I was pasting, please disregard the bold type rigt here:

$db->query("insert into orders(cookieId, cart_items, order_date ,order_status) on the insert code on the first post.

Also, I think I posed in the wrong forum...
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.