creating a loop for printing invoice detail (need help here)
Posted: Sun Nov 20, 2011 3:17 pm
i want to make the code to print up to 100 detail lines of an invoice.
If $name_X has a value, then print the line with all the info (itemno_X, Name_X, Qty_X, Price_X etc. etc..)
In my code i did 20 lines manually and it is printing the invoice right, no problem. So the only thing missing is creating the loop do print up to 100 lines.
Here is the code i have to print 20 lines :
etc etc.... for 20 lines....
So basically, it is printing the line IF there is information inside $NAME_X
I am sure there is something that can be done to loop it 100 times avoiding to write 100 lines manually.
(Waiting for Celauran here
)
now, with the way the code is written, it is printing the varialbe name instead of the content of it.
thanks again for helping.
If $name_X has a value, then print the line with all the info (itemno_X, Name_X, Qty_X, Price_X etc. etc..)
In my code i did 20 lines manually and it is printing the invoice right, no problem. So the only thing missing is creating the loop do print up to 100 lines.
Here is the code i have to print 20 lines :
Code: Select all
if( $NAME_0 ) {$strMessageBody .= "<TR ><TD>$ID_0 </TD><TD> $NAME_0</TD><TD align='right'>$QUANTITY_0</TD><TD align = 'right'>$PRICE_0 </TD><TD align = 'left'>/$UofM_0</TD><TD align = 'right'>$extvalue</TD></TR>";}
if( $NAME_1 ) {$strMessageBody .= "<TR><TD>$ID_1 </TD><TD> $NAME_1</TD><TD align='right'>$QUANTITY_1</TD><TD align = 'right'>$PRICE_1 </TD><TD align = 'left'>/$UofM_1</TD><TD align = 'right'>$extvalue</TD></TR>";}
if( $NAME_2 ) {$strMessageBody .= "<TR><TD>$ID_2 </TD><TD> $NAME_2</TD><TD align='right'>$QUANTITY_2</TD><TD align = 'right'>$PRICE_2 </TD><TD align = 'left'>/$UofM_2</TD><TD align = 'right'>$extvalue</TD></TR>";}So basically, it is printing the line IF there is information inside $NAME_X
I am sure there is something that can be done to loop it 100 times avoiding to write 100 lines manually.
(Waiting for Celauran here
Code: Select all
for ($x = 0; $x <= 100; $x++) {
$STRNAME = '$NAME_' . $x ;
$STRQTY = '$QUANTITY_' . $x;
etc... etc... for all the other fields of info.
if ($STRNAME) {$strMessageBody .= "<TR ><TD>$STRNAME </TD><TD>$STRQTY </TD></TR>";}
}thanks again for helping.