Friday, 15 February 2013

Echo comma separated values in php -


I have an invoice table with values ​​separated by commas in 3 columns, now I have a report in the description of each invoice Want to show Example:

  invoice_id = 10 products = 1,5,55 square = 2,44,25 qt = 55,2,10  

for up So invoices, I want to show the name and category of each product with a square.

If they are in correct order and a consistent correlation, you can do this. For example, you can blast from the ',' field and create output in such loops:

  / / You need to get data from the database, for each invoice field Strings $ product = "1,5,55" $ range = "2,44,25" $ QTY = "55,2,10" // is: $ products = explosion (',', $ product); $ Ranges = explosion (',', $ range); $ QTYs = Explosion (',', $ QTY); ($ I = 0; $ i & lt; Count ($ product); $ i ++) {resonant "product:" $ products [$ i] ", category:". $ Ranges [$ i] ", quantity:". $ Quits [$ i] ". & Lt; br & gt;"; }  

Hope it helps


No comments:

Post a Comment