$query = "select * from forumo_pranesimai where temos_id='x' order by id desc limit 1": $a = mysql_query($query); $b = mysql_fetch_assoc($a); echo "<a href='xxx.php?temos_id=x&pranesimas={$b['id']}'>Temos pavadinimas</a>";