[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need to repeat MySQL query results X number of times - Returns "Line Item" Need to echo per Quantity Count

Posted on 2008-10-12
4
Medium Priority
?
901 Views
Last Modified: 2013-12-13
Query pulls records from 5 db tables and returns Account Receivable by line item (e.g. First Name || Last Name || Company || Product Part Number || Line Item QUANTITY

EXAMPLE OF OUTPUT:
++++++++++++++++++++++++++++++++++++++++++
Bill Smith - AJAX Inc.
p/n: 123-X555 10 EA
++++++++++++++++++++++++++++++++++++++++++
I am working on a routine to print labels and need to output something similar to:

++++++++++++++++++++++++++++++++++++++++++
Bill Smith - AJAX, Inc.
p/n: 123-X555 1 of 10
++++++++++++++++++++++++++++++++++++++++++
Bill Smith - AJAX, Inc.
p/n: 123-X555 2 of 10
++++++++++++++++++++++++++++++++++++++++++
Bill Smith - AJAX, Inc.
p/n: 123-X555 3 of 10
++++++++++++++++++++++++++++++++++++++++++
And So On...can't get this to output right...I must be missing something.

Some but not all queries will have more than one line item. So, My SELECT/WHILE statements are pulling correctly, I've just not nailed how to get an echo per "Quantity" count

Thanks!

PS - I've not added a snippet because (for one its actually rather confusing) but mainly because I know its got to be a modification to the while loop and I'm hoping someone can give me this in principle or at least cite a ref and I'll look it up.
0
Comment
Question by:Rapturer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 1500 total points
ID: 22699113
Try something like this:
foreach($dataset as $row) {
  for($counter=1;$counter<=$row['Quantity'];$counter++) {
    echo $row['First'].' '.$row['Last'].' - '.$row['Company']."\n" 
         'p/n:'.$row['PartNbr'].' '.$counter.' of '.$row['Quantity']."\n";
  }
}

Open in new window

0
 
LVL 1

Author Comment

by:Rapturer
ID: 22699130
Thank you CXR - I'll fire it up now and get back!

-Rapturer
0
 
LVL 39

Assisted Solution

by:Roger Baklund
Roger Baklund earned 1500 total points
ID: 22709730
I answered the question:

for($counter=1;$counter<=$row['Quantity'];$counter++)

You got the same answer in question 23810852, this from  angellll:

$quantity = $therecord["quantity"];
for ($loop_quantity=1, $loop_quantity <= $quantity, $loop_quantity++)

... and this from nahime, which you accepted:

for ($i = 1; $i <= $therecord["quantity"]; $i++)

I gave the correct answer first.
0
 
LVL 1

Author Closing Comment

by:Rapturer
ID: 31505496
I dont wish to argue...however Nahime's answer was the most complete...he provided the entire function. My first question did not include the code snippet hence the fault is largely mine. Awarding points.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question