Código PHP:
<?php
include ("conexion.php");
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
$busquedamascotas = mysql_query("SELECT * FROM fotos ORDER BY horafecha DESC LIMIT 20", $db);
while($mascotas=mysql_fetch_array($busquedamascotas)){ ?>
<a href="<?php $mascotas['foto']; ?>" rel="lytebox" title="<?php $mascotas['title']; ?>"><img src="<?php $mascotas['thumb']; ?>" style="border: medium none;" alt="<?php $mascotas['title']; ?>"></a><?php } ?>
Muchas gracias de antemano! :D