Link to home
Start Free TrialLog in
Avatar of mikemaner
mikemaner

asked on

PHP Development Issue - the sequel

I have this code in place to define the quantity function (thx Brian:)...

<?php
$qty_string = "<input type=\"text\" size=\"2\" name=\"qty[]\" style=\"font-family: verdana; font-size: 8pt\" value=\"";

// Item 1
$qty = $_POST["qty"][0];                  // Quantity after Update
$with_disc01 = round( (($price01*(round($discount01/100, 2)))-$price01), 2);
$ext_npl01 = ($price01*$qty);
$ext_inst01 = ($inst01*$qty);
$ext_maint01 = ($maint01*$qty);
$ext_usc01 = ($cost01*$qty);
// Item 2
$qty = $_POST["qty"][1];                  // Quantity after Update
$with_disc02 = round( (($price02*(round($discount02/100, 2)))-$price02), 2);
$ext_npl02 = ($price02*$qty);
$ext_inst02 = ($inst02*$qty);
$ext_maint02 = ($maint02*$qty);
$ext_usc02 = ($cost02*$qty);
// There will be a total of 64 Items, this is just 2 of them
?>

So now I am working on creating totals and am looking for a way to use the existing quantities specified by the user, per item, to create them.  I have tried a few different ways, but being a n00b I'm not having much luck.  Here's an example of what I have tried...

<?php
$x_ext_npl = (($price01*$qty_string . $_POST["qty"][0])+($price02*$qty_string . $_POST["qty"][1])+($price03*$qty_string . $_POST["qty"][2]));
$x_ext_inst = (($inst01*$qty_string . $_POST["qty"][0])+($inst02*$qty_string . $_POST["qty"][1])+($inst03*$qty_string . $_POST["qty"][2]));
$x_ext_maint = (($maint01*$qty_string . $_POST["qty"][0])+($maint02*$qty_string . $_POST["qty"][1])+($maint03*$qty_string . $_POST["qty"][2]));
$x_ext_usc = (($cost01*$qty_string . $_POST["qty"][0])+($cost02*$qty_string . $_POST["qty"][1])+($cost03*$qty_string . $_POST["qty"][2]));
$x_ext_disc = (($with_disc01*$qty_string . $_POST["qty"][0])+($with_disc02*$qty_string . $_POST["qty"][1])+($with_disc03*$qty_string . $_POST["qty"][2]));
?>

Welll, it didn't work :)  Anyone have any ideas?  thanks for the help.
ASKER CERTIFIED SOLUTION
Avatar of Tomeeboy
Tomeeboy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So the whole thing would look like this:

$x_ext_npl = (($price01*$_POST["qty"][0])+($price02*$_POST["qty"][1])+($price03*$_POST["qty"][2]));
$x_ext_npl = (($inst01*$_POST["qty"][0])+($inst02*$_POST["qty"][1])+($inst03*$_POST["qty"][2]));
$x_ext_npl = (($maint01*$_POST["qty"][0])+($maint02*$_POST["qty"][1])+($maint03*$_POST["qty"][2]));
$x_ext_npl = (($cost01*$_POST["qty"][0])+($cost02*$_POST["qty"][1])+($cost03*$_POST["qty"][2]));
$x_ext_npl = (($with_disc01*$_POST["qty"][0])+($with_disc02*$_POST["qty"][1])+($with_disc03*$_POST["qty"][2]));
Avatar of mikemaner
mikemaner

ASKER

That was it, thanks m8, I am still a bit confused by syntax at this point.  I 'AM' learning though :)