Limiting String Print

I have a database of 100 lines which have echoed onto the page so each line within the database is printed. I would like to limit it to ten. However, I have tried a whole range of different loops but none of them seek to work.

Some of them print the database ten times so I have 1000 lines on the page. Can anyone advise the best method of limiting how many lines within a database are printed on the page?

Are the lines printed on new lines within the database already? If they are you can do something like.

$res = mysql_query("SELECT my_row FROM table_name");
$query_result = mysql_fetch_row($res);
$query_result = array_slice(explode("\
", $query_result), 0, 10);

echo '<pre>';
echo '</pre>';

Why not just add a “LIMIT 10” clause to the MySQL query?