title: Add LIMIT query in php
body: <p>How can I add LIMIT query in it? I have adding it in </p>
  
  <pre><code>$SQL = "SELECT * FROM eins_policy LIMIT 500 ";
  </code></pre>
  
  <p>but it did not display the list.</p>
  
  <p><a href="https://i.stack.imgur.com/OH3jL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OH3jL.png" alt="enter image description here"></a></p>
  
  <p>For example:</p>
  
  <ul>
  <li>If I choose 500 records per page;</li>
  <li>Total records is 3560 records;</li>
  <li>If now I on page 1, meaning (Page number – 1) * 500 = 0, and my  Offset is 0;</li>
  <li>If now I on page 2, meaning (Page number – 1) * 500 = (2 – 1) * 500 = 500, and Offset is 500, meaning 501 to 1000 is the records fetched;</li>
  <li>If now I on page 3, meaning (Page number – 1) * 500 = (3 – 1) * 500 = 1000, and Offset is 1000, meaning 1001 to 1500 is the records fetched;</li>
  </ul>
  
  <h2>policylist.php</h2>
  
  <pre><code>function eins_listPolicy($page, $record ,$search)
  {
      //connect to database
      base_connectDatabase();
  
      $searchs = explode(" ", $search);
  
      $SQL = "SELECT * FROM eins_policy ";
      $countSearch = 0;
  
      foreach ($searchs as &amp;$value) {
          if ($countSearch == 0) {
              $SQL .= "WHERE ";
          } else {
              $SQL .= "AND ";
          }
          $SQL .=  "(eins_plcy_code LIKE '%".$value."%' OR
                      eins_plcy_client IN (SELECT eins_clnt_id FROM eins_client WHERE eins_clnt_full_name LIKE '%".$value."%') OR
                      eins_plcy_insurance_company IN (SELECT eins_icomp_id FROM eins_insurance_company WHERE eins_icomp_name LIKE '%".$value."%') OR
                      eins_plcy_agent IN (SELECT eins_agent_id FROM eins_agent WHERE eins_agent_user_id IN (SELECT base_u_id FROM base_users WHERE base_u_name LIKE '%".$value."%')) OR
                      eins_plcy_policy_type IN (SELECT base_u_id FROM base_users WHERE base_u_name LIKE '%".$value."%') OR
                      eins_plcy_start_date LIKE '%".$value."%' OR
                      eins_plcy_end_date LIKE '%".$value."%' OR
                      eins_plcy_payment_status = '".$value."' OR
                      eins_plcy_status LIKE '%".$value."%')
                 ";
          $countSearch ++;
      }
  
      $result = base_executeSQL($SQL);
      $total = base_num_rows($result);
      if(is_int($total/$record)) {
          $tpages = $total/$record;
      } else {
          $tpages =  floor($total/$record)+1;
      }
  
      $start = $record * ($page-1);
      $adjacents = 3;
      $reload = 'policy_list.php';
      $count = 0;
      $zeroRecord = false;
  
      $RSQL = "LIMIT ".$start.", ".$record."";
  
      $getPolicySQL = base_executeSQL($SQL.$RSQL);
      while($Policy_row = base_fetch_array($getPolicySQL))
          if (base_num_rows($getPolicySQL)!= 0) {
              $inscompName = eins_getInscompDetail($Policy_row["eins_plcy_insurance_company"]);
              $agentName = eins_getAgentDetail($Policy_row["eins_plcy_agent"]);
              $clientName = eins_getClientDetail($Policy_row["eins_plcy_client"]);
              $polocytypeName = eins_getPolicytypeDetail($Policy_row["eins_plcy_policy_type"]);
              $count = $count + 1;
              echo "&lt;tr&gt;";
                  echo "&lt;td&gt;". $count ."&lt;/td&gt;";
                  echo "&lt;td&gt;&lt;a href = \"../einsurance/view_policy.php?id=". $Policy_row["eins_plcy_id"] ."&amp;page=".$page."&amp;record=".$record."&amp;search=".$search."\"&gt;". $Policy_row["eins_plcy_code"] ."&lt;/a&gt;&lt;/td&gt;";
                  echo "&lt;td&gt;". $polocytypeName['eins_ptype_name'] ."&lt;/td&gt;";
                  echo "&lt;td&gt;". $inscompName['eins_icomp_name'] ."&lt;/td&gt;";
                  echo "&lt;td&gt;". $agentName['eins_agent_full_name'] ."&lt;/td&gt;";
                  echo "&lt;td&gt;". $clientName['eins_clnt_full_name'] ."&lt;/td&gt;";
                  echo "&lt;td&gt;". $Policy_row["eins_plcy_payment_status"] ."&lt;/td&gt;";
                  echo "&lt;td&gt;". $Policy_row["eins_plcy_status"] ."&lt;/td&gt;";
                  echo "&lt;td&gt;&lt;a href = \"../einsurance/edit_policy.php?id=". $Policy_row["eins_plcy_id"] ."&amp;page=".$page."&amp;record=".$record."&amp;search=".$search."\"&gt;&lt;img src=\"". BASE_IMG_ICON_EDIT ."\" /&gt;&lt;/a&gt;&lt;/td&gt;";
                  echo "&lt;td&gt;&lt;a href = \"../einsurance/delete_policy.php?id=". $Policy_row["eins_plcy_id"] ."&amp;page=".$page."&amp;record=".$record."&amp;search=".$search."\" onclick=\"return confirm ('".MSG_CONFIRM_DELETE."')\"&gt;&lt;img src=\"". BASE_IMG_ICON_DELETE ."\" /&gt;&lt;/a&gt;&lt;/td&gt;";
              echo "&lt;/tr&gt;";
          }
          if (base_num_rows($getPolicySQL)== 0) {
              echo "&lt;tr&gt;&lt;td colspan = \"9\" align = \"center\"&gt;There is no record!&lt;/td&gt;&lt;/tr&gt;";
              $zeroRecord = true;
          }
          if($zeroRecord == false) {
              echo "&lt;tfoot bgcolor=\"white\"&gt;";
                  echo "&lt;tr&gt;";
                      echo "&lt;td colspan=\"10\"&gt;";
                          $record .= "&amp;search=".$search;
                          eins_paginate($reload, $page, $tpages, $adjacents, $record, $total) ;
                      echo "&lt;/td&gt;";
                  echo "&lt;/tr&gt;";
          }
          //close the database
          base_closeDatabase();
  }
  </code></pre>