You do have to have a connect established before you can make any queries to the database.
The way most accomplish this, is to include the connect script on top of pages they need connectivity.
The connect script needs only to be included once for the page to work, even if it includes other files, they can all use that single connect script unless of course they connect eslewhere.
so
if you connect.php is
<?PHP
if ($DB=mysql_connect("localhost", "myusername", "mypass")) mysql_select_db("MyDB");
?>
then on your rows.php all you need to do is
<?PHP
include("connect.php");
the rest of your php.....
then that file will share that connect.php $DB link