[php] Query within while loop

So this problem is sort of wierd.
I’m going to display the code first so it’ll make more sense what I’m talking about.

 $lastCon = mysql_query("SELECT * FROM entries ORDER BY ID DESC LIMIT 5");
 $conCat = mysql_query("SELECT * FROM category ORDER BY name");
 echo '<h3>Last 5 entries</h3>';
 while($last5 = mysql_fetch_assoc($lastCon)){
 	echo '<p><span class="id">ID:</span>' . $last5['ID'] . '&nbsp;&nbsp;<a href="http://www.xxviii.net/bawks/entryView.php?id=' . $last5['ID'] . '">' . $last5['title'] . '</a>&nbsp;&nbsp;' . $last5['date'] . '&nbsp;&nbsp;' . $last5['time'] . '</p><p class="edFoot"><a href="main.php?page=eddEn&en=' . $last5['ID'] . '">Edit</a>&nbsp;|&nbsp;<a href="main.php?page=eddEn&en=' . $last5['ID'] . '&del=1">Delete</a></p>';
 while($lastCat = mysql_fetch_assoc($conCat)){
 	$cat = $lastCat['name'];
 	$queerCat = mysql_query("SELECT * FROM entries WHERE category='$cat' ORDER BY ID DESC LIMIT 1");
 	echo '<h3>' . $cat . '</h3>';
 	echo $queerCat['title'];

The first while loop is fine, no problem there. The second while loop is what is really confusing me.
See it’s supposed to dynamically list the last entry in each category, and the list of categories is supposed to be dynamically listed as well. What’s bothering me is the mysql_query variable, affectionately dubbed $queerCat. I need the variable to change names each time the while loop is processed, but I have no idea how. So when I echo out the variable, nothing shows up.

I honestly don’t know what to do here, I don’t even know if this is the right approach as I’m still fairly new to all of this. Any help whatsoever would be fantastic. Thanks everyone :slight_smile: