Jump to content

Search the Community

Showing results for tags 'php pdo array_sum'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. I'm trying to get total price from cart table. The product_price in other table which is product. I'm only getting the latest price not the total price. Thanks function total_price () { $total = 0; global $db; $ip = getIp(); $sql = $db->query("SELECT * from cart WHERE ip_add='$ip'"); $row = $query->fetch(PDO::FETCH_ASSOC); if ($row) { } $no=$sql->rowCount(); // number of rows affected by the last SQL statement if ($no == 0) { echo ""; } else { foreach($sql as $row) $product_id = $row["p_id"]; $sql = $db->query("SELECT product_price from product WHERE product_id='$product_id'"); $no=$sql->rowCount(); // number of rows affected by the last SQL statement if ($no == 0) { echo ""; } else { foreach($sql as $row) $product_price = array($row["product_price"]); $values = array_sum($product_price ); $total += $values; } } echo "RM" . $total; } } I'm trying to get total price from cart table. The product_price in other table which is product. I'm only getting the latest price not the total price. Thanks
×
×
  • Create New...