Really don't see any difficulty if I am right. Is this want you want, run this code once and see the source code produced, is this what you want:
<?PHP
$dbq="\"";//these help read code easy
//this array is just for testing purpose
$rows['id']=5;
$rows['name']='John';
$rows['photo']='test.png';
//you could go this way, commas and single quotes
//are always faster than concatenation and double quotes
echo '<td><div align="center"><a href=',$dbq,'http://',$_SERVER['HTTP_HOST'],$_SERVER['REQUEST_URI'],
'?id=',$rows['id'],$dbq,'><img src=',$dbq,'sp_pics/',$rows['photo'],$dbq,' alt=',$dbq,$rows['name'],$dbq,
' width="76" height="85" border="0"><br/></a>',$rows['name'],'<strong> id:',$rows['id'],'</strong></td>';
?>