I have a MySQL table called "invoice_prod" :
id | qte | price | id_tva
And another table called "tva" :
id_tva | content
Now, I want to find the total of an invoice, so I made this query and it works.
$sql_mnt = mysql_query("
SELECT SUM( (qte * price) * ( 1 + (tva / 100))) AS total_un_prod
FROM invoice_prod
WHERE id='$id_invoice'
");
I have just one problem with this query. The "tva" return the "id of the tva" and not its content. Which I have to extract its content from the table "tva".
Clearly, this query return this value of the tva : "1", or, it should return "18%" which is the content of the tva's ID.
I tried to make a PHP function that extracts the tva's content from an id and include it into the SQL query like this :
$sql_mnt = mysql_query("
SELECT SUM(( qte * price) * ( 1 + (" .
tva_get_by_id(tva) . "/ 100))) AS total_un_prod
FROM invoice_prod
WHRE id='$id_invoice'
");
But it doesn't work.
What should I do ?
Thanks a lot for your help and have a nice day :)