fighting with functions
| From: | Sara Daugherty | Date: | Fri, 21 Nov 2003 09:56:34 +0000 |
| Subject: | fighting with functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-170521@lists.php.net to get a copy of this message | ||
I could use a little help. click on the link to see my php code for a project that creates an array with a list or items and their cost and calculates tax by using a function called getTax() and also creates a balance by adding the cost plus the tax in a second function called getBalance(). I must also create a table where the cells automatically load so the end result looks like this.
http://www.areawebdirectory.net/taxtable2.txt
Item Cost Tax Running Total Car 10000.00 600 10600.00 Pencil 1.00 .06 10601.06 Book 14.95 .097 10616.98I cant seem to first be able to declare my array and succeed at naming the key as item and the value as price. I have attempted to use variations of the following with no success. $items = array ( 0 => array ("item"=>"car","price"=>15000, "tax"=>.065 ), 1 => array ("item"=>"pencil","price"=>1, "tax"=>.065 ), 2 => array ("item"=>"book","price"=>14.95, "tax"=>.065)
); Without being able to declare the key as item and the value as price I am not sure how to pass these items into my function and I am riddled with error messages. I think my base problem is to either fix how I am declaring the array so I may reference "item" and "price" as I am now doing in my functions or learn how to change the functions accordingly.I am also pretty sure that my functions are not quite right. I am also not sure how to link the right answers to get my table to print as above. Please note that I have included a while loop after my array just to prove that my array is working. It is needed part of my program. I also have given each cell in my table some text just so I can find them when I have figured out how to create the right reference links. I am sorry that I need as much help with this. Sadly I have been at this for almost two weeks trying to solve it. Thanks, Sara