Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


PHP Development Issue - the sequel

Posted on 2006-03-25
Medium Priority
Last Modified: 2006-11-18
I have this code in place to define the quantity function (thx Brian:)...

$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...

$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.
Question by:mikemaner
  • 2
LVL 15

Accepted Solution

Tomeeboy earned 2000 total points
ID: 16291228
Is it just me, or are you trying to multiple a numeric value with a string? :)  Try this instead:

$x_ext_npl = (($price01*$_POST["qty"][0])+($price02*$_POST["qty"][1])+($price03*$_POST["qty"][2]));
LVL 15

Expert Comment

ID: 16291248
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]));

Author Comment

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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to implement server side field validation and display customized error messages to the client.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question