Question: How can I take the output of a while loop and pass it to a for loop?

I get some id from my sql db using while loop. Now, how to pass each id to select query?

For example:

```
while($row = mysql_fetch_array($sql)) {
    $y= $row['c'];
} 

```

How can I pass each $y to a select query?

Answer: 
> 
> from what I know the compiler does not optimize this kind of code
> 
> 
> 

The Hotspot JIT compiler [most definitely does](http://java.sun.com/developer/technicalArticles/Networking/HotSpot/inlining.html).

> 
> I was wondering what's the best solution?
> 
> 
> 

Stop optimizing prematurely. If you're using this code in a painting routine, I can guarantee that the actual painting will take at least a hundred times longer than calling a trivial method, even if it's not inlined.
Actually the HotSpot compiler would most likely inline calls to your getters, so no overhead will be involved (besides, the overhead for calling these methods would hardly be measurable).

**EDIT**

If you *really* need every CPU cycle, use C or C++ (or write performance-critical parts in it and call it via JNA, though its unlikely that it will be worth the time spent).