Rather vague question, but sounds relatively simple enough. Each 'add' and 'subtract' will be links back to your CGI script that will pass the product id as well as the new values along. You can precalculate them when you generate the links or you can fetch the current value from the database just before you update the values.

In your script, test for an add or subtract request and either use the new value passed from the script or fetch the current value from the database.

If you choose the former, just UPDATE with that value (don't forget to validate ALL user input - trust no one!). If you did a lookup, add one or subtract one accordingly (i recommend one sub for add and one for subtract in this case), and UPDATE to the database.

If you wish to do a 'global' add or subtract - then you will need to pass all the id's of each product - be sure and use the POST method, as this request will be quite large.

Jeff

R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--

In reply to (jeffa) Re: Recalculating DB values by jeffa
in thread Recalculating DB values by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.