adamschroeder. An important thing to note is that using mysql_fetch_assoc() is not significantly slower than using mysql_fetch_row(), while it provides a significant added value. PHP. I am using php to display the data of the two columns id & product_name in each row. But the problem is that I'm running a mysql_query within a while loop, which I was told I should avoid. Read "Differences between a while loop and a for loop in PHP… September 5, 2014, 2:01am #1. combining SQL and HTML in one function is a sign of VERY BAD design. This means that the do...while loop will execute its statements at least … Loops are used to execute the same block of code again and again, as long as a certain condition is met. Im trying to build an online tool checkout application, so Im working with script 10.5 to pull (tool names) from a database to populate a table. While Loop in MySQL. 3. Start New Topic. WHILE MyCondition DO--Commands. The while loop, which is one of the loops used in programming languages, is used for repetitive operations according to a condition. I have a question regarding using a while loop to display the contents of a table. Okay, here is complete code: