Hello,
I am writing a invoice script, but don’t know how to go about this.
I have two tables i..e “invoice” and “invoice_items”
Here’s the table structure for invoice_items with demo content
id | invoiceid | title | qty | amount
1 | 1 | this is a new invoice item | 2 | 299
2 | 1 | this is another item | 1 | 399
3 | 1 | this is another item for invoice 1 | 1 | 600
4 | 2 | invoice 2 item | 1 | 600
What i want to do is
1. display all the invoice items related to invoiceid 1 – DONE
2. display total price for each invoice item (qty * amount) – DONE
3. Display grand total : i don’t know how to do this…(ran our of ideas)
So, can anyone help me out and guide me in the right direction??
I suggest you to first learn php and MySql , you can find good tutorials of nettuts 
Well, i know both php and mysql, i just don’t know how to go about this..,
I mean first i have to loop through all invoice_items table, after that i have to select invoice_items with invoiceid 1, after doing this i have to multiply amount with qty and then display all these data
At the end, i have to add all the amount i..e total price (in this case 3) and display it as grand total.
BTW , I know i can / will find goood tutorials at nettuts 
@5thSenseLabs
I see you are releasing an Invoice Management Application by next week,
Even i am planning to launch my Application by next week (max 2 weeks), so you can be sure of some competition
(atleast a little.)
I hav been working on my application for 3 weeks now, should be releasing this weekend..
.. as far as the table is concerned, I think you are confused about how to work with invoice items in the table, for that just create a column invoice_item add the items separated by example comma, use php explode function to work with them… no need for 2 tables
This is exactly(sort of) what i was looking for earlier.., but i will use it now.
Can you post some screenshots or demo of your app??? 
sure here it is … http://twitpic.com/25utz5 , it has invoice, client, project, estimate and events management 
Looks Great. Have you made use of jquery/ajax or not?
I hav been working on my application for 3 weeks now, should be releasing this weekend.... as far as the table is concerned, I think you are confused about how to work with invoice items in the table, for that just create a column invoice_item add the items separated by example comma, use php explode function to work with them… no need for 2 tables
Or instead of explode you could also use serialize / unserialize.
Not to take over the thread or anything have either of you checked out Invoice Bubble?
Back on track, so you say you have two tables. You could do this in php or MySQL.
PHP
I haven’t tested this, and it isn’t fully completed or anything but just helping along the tracks.
// grab invoice
$invoice = $Invoices->get(1); // Invoice Class returns Invoice Information for Invoice 1
$invoice_items = $Invoices->getItems(1); // Same as above
// Both of these return an Array
$grand_total = 0;
foreach($invoice_items as $item)
{
$grand_total += ($item['qty'] * $item['amount'];)
}
The other way you can do this is using SQL to create a column
select title, qty, amount, (qty * amount) as total from invoice_items where invoiceid = 1
@dhruv yup jQuery interface ... and @TutelageSystems serialize is also a good solution nice one buddy
, not much of use in my app so didnt mentioned it 
