Separating HTML from PHP is the best method. It's less confusing and easy to debug.
<?php
while($var)
{
?>
<div>
<h3><a href="User<?php echo $i;?>"><?php echo $i;?></a></h3>
<div>Lorem ipsum dolor sit amet.</div>
</div>
<?php
$i++;
}
?>