I have a while loop of a mysql call but I also am trying to run another mysql query inside of the while loop but it is only doing it once. I can not figure it out.

Here is my code:

```
$sql = "SELECT * FROM widget_layout WHERE module_id=".mysql_real_escape_string($id)." AND state='".mysql_real_escape_string($page)."' AND position=".mysql_real_escape_string($position);

$query = mysql_query($sql);
while ($row = mysql_fetch_assoc($query)) {
    $layout .= $row['widget_id'].'<br/>'; //test if it is looping through all rows
    $sql2 = "SELECT title FROM widgets WHERE id=".$row['widget_id'];
    $query2 = mysql_query($sql2);
    $result2 = mysql_fetch_array($query2);
    $layout .= $result2[0]; // test the title output
}

```

It is looping through the first query no problem but the second query is only load the title of the first widget, return null for the rest. Any idea of why this is doing this?