MySQL Database Php

//A sample function that I made that will limit the number of
//rows from mysql to be display each page where $start is
//the starting row, $trows is the total number of rows and $rown
//is the number of rows to be display each page.
$host=""; //hostname
$user=""; //user
$password="";//password
$db="dbname"; //database name
$tbl="table"; //table name
$rown="5"; //number of rows to be display each page
//The functions
function first($start,$trows,$rown)
{
if ($start == $trows-intval($trows%$rown)&&$trows>$rown ||$start<>intval(0))
{
$first="First";}
else
{
$first="First";
}
return $first;
}
function previous($start,$trows,$rown)
{
if ($start >= $trows-intval($trows%$rown)&&$trows>$rown||$start<>intval(0))
{
$prev=$start-$rown;
$previous="Previous";
}
else
{
$previous="Previous";
}
return $previous;
}
function next1($start,$trows,$rown)
{
if ($start < ($trows-intval($trows%$rown))&&(($start+$rown)-$trows<>"0"))
{
$next=$start+$rown;
$next="Next";
}
else
{
$next="Next";
}
return $next;
}
function last($start,$trows,$rown)
{
if ($start < $trows-intval($trows%$rown)&&(($start+$rown)-$trows<>"0"))
{
if (($rem=$trows%$rown)==0){$rem=$rown;}
$last=intval($trows-$rem);
$last="Last";
}
else
{
$last="Last";
}
return $last;
}
//end of the functions
mysql_connect($host,$user,$password);
mysql_select_db($db);
$query="select * from $tbl";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);//total number of rows equal to $trows;
if ($start=="")
{$start=0;}
$query="$query limit $start,$rown"; //limit output $rown=5 rows starting $start
$result=mysql_query($query);
print"






";
while ($row=mysql_fetch_array($result))
{
print"





";
}
print"
Field1 Field2 Field3 Field4 Field5
$row[0] $row[1] $row[2] $row[3] $row[4]
";
print"




".first($start,$numrows,$rown)." ".previous($start,$numrows,$rown)." ".next1($start,$numrows,$rown)." ".last($start,$numrows,$rown)."
";
?>