Home > MySQL, PHP > Foreach Loops

Foreach Loops

December 6th, 2009

Hello

This should be a really quick and easy job. I just need to iterate through a mysql array and declare values using the results but I need multiple sets of each declaration… for example

product1_description
product2_description etc..

The number in the after the word product obviously needs to go up for each product in the mysql result.

I have most of the code already done I just need the above and the part of an XML creation that deals with those values.

There can be any number of products in the results so both the declarations and the xml portion need to be completely dynamic.

Following are the pieces of the script you will be working with…

$line1_LineNumber = ’1′;

$line1_Product = ‘Product1′;

$line1_Description = ‘A description1′;

$line1_Quantity = ’1′;

$line1_Price = ’10.00′;

$line1_DeclaredValue = ’10.00′;

— and the XML —

‘ <PLOrderLine>’.

‘ <LineNumber>’.$line1_LineNumber.’</LineNumber>’.

‘ <Product>’.$line1_Product.’</Product>’.

‘ <Description>’.$line1_Description.’</Description>’.

‘ <Quantity>’.$line1_Quantity.’</Quantity>’.

‘ <Price>’.$line1_Price.’</Price>’.

‘ </PLOrderLine>’.

This entire section of the XML needs to iterate if there are multiple products in the results and I need everywhere you see the number 1 to count up.

everywhere you see the number 1 needs to be dynamic.

I wrote this pretty quickly so if it doesnt make sense please let me know.

I need this done today so please keep that in mind when bidding.

Thanks


Foreach Loops

Comments are closed.
Bear