<? $q=mysql_query("SELECT * FROM `smile` where `dir` = '21' OR `dir` = '20' limit 70"); while($post = mysql_fetch_array($q)){ $x="'$post[smile]'"; echo '<a href="javascript:emoticon('.$x.')"><img src="/style/smiles/'.$post['name'].'" alt="'.$post['name'].'"/></a>'; } ?>