$q = mysql_query("SELECT `id`,`groups_name` FROM `groups`");
while($r = mysql_fetch_array($q)){
$id_q = <<<TXT
$r[id]
TXT;
$name = <<<TXT
$r[groups_name]
TXT;
echo<<<TXT
<table border=1>
<tr><td><a href="index?p=$id_q">$name </a> <br> <img width="120" src="$small_ava"><br></td></tr>
</table>
TXT;