I noticed that most if not all the mysql_fetch_object, and mysql_fetch_array and mysql_fetch_row all have print in the while brackets... what I want to do is to assign the result to a $variable first WITHOUT printing the result, and reassigning the $variable into a second query, before printing... how should this be done the right way, because I've been getting parse errors. Here's what I want to do: $FirstQuery = select * from table where field = condition then with PHP $variable = while ( ) { statement about the first query becomes a long string } After this, I want to go back to MySQL $SecondQuery = select * from table where field = $variable How can I do this without nesting, but assigning a $variable instead to place in the second query? What's an alternative solution to this?