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: 
Create a class with `public final` fields. Provide constructor where those fields would be initialized. This way your class will be immutable, but you won't have an overhead on accessing the values from the outside. For example:

```java
public class ShortCalendar
{
    public final int year, month, day;

    public ShortCalendar(Calendar calendar)
    {
        if (null == calendar)
            throw new IllegalArgumentException();

        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH);
        day = calendar.get(Calendar.DATE);
    }
}

```
yes.. we can make a variable read-only using **final** keyword

Ex: `public final int id = 10;`