As above I'm using PHP and MSSQL, and looking to be able to organise the contracts we have in a database by limiting them to 50 or so on a page.

Ive looked on the web, and I cant quite get my head around the code.

This is what I have got at the mo, and would love if somebody could help me out to be able to page all the contracts to 50 a page.

PHP Code:
<?php
if ($search==""){
  
$query "select * from Intranet order by ID DESC";
} else {
  
$query "select * from Intranet $search";


$stmt sqlsrv_query($conn$query);
while(
$data sqlsrv_fetch_array($stmtSQLSRV_FETCH_ASSOC))        
{
echo 
"<tr>";
echo 
"<td width='25' bgcolor='#ffffff' class='tableData'><a href='upload_contract.php?ID=".$data["ID"]."&Admin=Edit'><img src='images/icon_edit.gif' alt='Edit Item' height='13'></a></td>";
echo 
"<td width='25' bgcolor='#ffffff' class='tableData'><a href='read_contract.php?ID=".$data["ID"]."'><img src='images/icon_view.gif' alt='View Item &amp; Print'></td>";
echo 
"<td width='25' bgcolor='#ffffff' class='tableData'><a href='upload_contract.php?ID=".$data["ID"]."&AdminDelete'><img src='images/delete_Icon.jpg' alt='Delete Item'></a></td>";
echo 
"<td width='70' class='tableData'>".$data["Contract_Number"]."</td>";
echo 
"<td width='70' class='tableData'>".$data["Contract_Status"]."</td>";
echo 
"<td width='55' class='tableData'>".$data["Annual_Contract_Value"]."</td>";
echo 
"<td width='80' class='tableData'>Contract Start</td>";
echo 
"<td width='80' class='tableData'>Contract Current</td>";
echo 
"<td width='60' class='tableData'>".$data["Contract_Length"]."</td>";
echo 
"<td width='80' class='tableData'>Renewal Date</td>";
echo 
"<td width='110' class='tableData'>".$data["Site_Name"]."</td>";
echo 
"<td width='80' class='tableData'>".$data["Street"]."</td>";
echo 
"<td width='80' class='tableData'>".$data["City"]."</td>";
echo 
"<td width='100' class='tableData'>".$data["State"]."</td>";
echo 
"<td width='100' class='tableData'>".$data["Country"]."</td>";
echo 
"<td width='60' class='tableData'>".$data["Region"]."</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Group_Member"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='100' class='tableData'>".$data["Group_Name"]."</td>";
echo 
"<td width='45' class='tableData'>".$data["No_of_Rooms"]."</td>";
echo 
"<td width='90' class='tableData'>".$data["Type_of_Establishment"]."</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["CSF"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Food_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Swimming_Pool_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Legionella_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Fire_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Hurricane"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Green"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Guest"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Room_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Quality_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Supply_Safety"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>";
if (
$data["Tourcheck"]==1){
  echo 
"Yes";
} else {
  echo 
"No";
}
echo 
"</td>";
echo 
"<td width='60' class='tableData'>".$data["No_of_Modules"]."</td>";
echo 
"<td width='60' class='tableData'>".$data["Currency_of_Invoice"]."</td>";
echo 
"<td width='60' class='tableData'>".$data["No_of_audits_per_annum"]."</td>";
echo 
"<td width='60' class='tableData'>".$data["No_of_visits_per_annum"]."</td>";
echo 
"<td width='45' class='tableData'>".$data["Seasonal_or_Full"]."</td>";
echo 
"<td width='65' class='tableData'>".$data["Month_Opens"]."</td>";
echo 
"<td width='65' class='tableData'>".$data["Month_Closes"]."</td>";
echo 
"<td width='65' class='tableData'>".$data["Invoicing_Profile"]."</td>";
echo 
"</tr>";
}                
?>