<? $res=mysql_query("SELECT id FROM claves",$link); $row=mysql_fetch_array($res); echo substr($row["id"],0,6); ?>