Jump to content

gomac

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://gord.macleod.name/

Profile Information

  • Gender
    Not Telling
  • Location
    Toronto

gomac's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, first post. I\'m a bit of a cook-book coder, but I clean up well and generally smell nice. I\'m creating a small personal app for practice with PHP and MySQL and need to tug on some expert coatails. I have a returned MySQL array which is displaying just dandy on a PHP page with a SELECT - one of the elements of that array is a calculated variable $total, which is the quotient of two db fields pulled with the SELECT ($total = $units * $value;). There is a $total in every row in the array produced in a WHILE loop. Two questions: 1) Can someone tell me how I can access the $total values so that I can further add them up outside of the WHILE function? I can see them on the page, but am unclear how to target them and add them up outside of the above loop. A code example would be very helpful. 2) I can\'t seem to figure out how to format the above $total variable. Because it is created by muliplying two decimal format numbers, it returns numbers with multiple decimals - I only want .02, because it is a money figure. settype($total, \'integer\'); returns only integers, no decimals (duh)...settype($total, \'decimal (7,2)\'); doesn\'t work - but I do get three and four decimals... Thanks for any help - hope I\'m not boring anyone with my brainlessness. Gord
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.