Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try the following, this is an updated version of your code.</p> <p>Please read the comments that I made in it, this is just a sample of some good practices.</p> <pre><code>&lt;?php $limit = 500; $area = 'customers_list'; $prc = 'customer_list.php'; if($_GET['page']) { include('inc/functions.php'); $page = (int)$_GET['page']; // safety (page always needs to be an integer } else { $page = 1; } $limitvalue = $page * $limit - ($limit); $customers_check = get_customers(); $customers = get_customers($limitvalue, $limit); $totalrows = count($customers_check); ?&gt; &lt;!-- pid: customer_list --&gt; &lt;table border="0" width="100%" cellpadding="0" cellspacing="0" style="float: left; margin-bottom: 20px;"&gt; &lt;tr&gt; &lt;td class="col_title" width="200"&gt;Name&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="col_title" width="200"&gt;Town/City&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="col_title"&gt;Telephone&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php foreach($customers as $i =&gt; $customer) // foreach is easier to use, manage and troubleshoot { ?&gt; &lt;tr&gt; &lt;td colspan="2" class="cus_col_1"&gt;&lt;a href="customer_details.php?id=&lt;?php echo $customer['customer_id']; ?&gt;"&gt;&lt;?php echo $customer['surname'].', '.$customer['first_name']; ?&gt;&lt;/a&gt;&lt;/td&gt; &lt;td colspan="2" class="cus_col_2"&gt;&lt;?php echo $customer['town']; ?&gt;&lt;/td&gt; &lt;td class="cus_col_1"&gt;&lt;?php echo $customer['telephone']; ?&gt;&lt;/td&gt; &lt;td class="cus_col_2"&gt; &lt;a href="javascript: single_execute('prc/customers.prc.php?delete=yes&amp;id=&lt;?php echo $customer['customer_id']; ?&gt;')" onClick="return confirmdel();" class="btn_maroon_small" style="margin: 0px; float: right; margin-right: 10px;"&gt;&lt;div class="btn_maroon_small_left"&gt; &lt;div class="btn_maroon_small_right"&gt;Delete Account&lt;/div&gt; &lt;/div&gt;&lt;/a&gt; &lt;a href="customer_edit.php?id=&lt;?php echo $customer['customer_id']; ?&gt;" class="btn_black" style="margin: 0px; float: right; margin-right: 10px;"&gt;&lt;div class="btn_black_left"&gt; &lt;div class="btn_black_right"&gt;Edit Account&lt;/div&gt; &lt;/div&gt;&lt;/a&gt; &lt;a href="mailto: &lt;?php echo $customer['email']; ?&gt;" class="btn_black" style="margin: 0px; float: right; margin-right: 10px;"&gt;&lt;div class="btn_black_left"&gt; &lt;div class="btn_black_right"&gt;Email Customer&lt;/div&gt; &lt;/div&gt;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td class="col_divider" colspan="6"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; &lt;!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--&gt; &lt;!--// PAGINATION--&gt; &lt;!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--&gt; &lt;div class="pagination_holder"&gt; &lt;?php if($page != 1) { $pageprev = $page-1; ?&gt; &lt;a href="javascript: change('&lt;?php echo $area; ?&gt;', '&lt;?php echo $prc; ?&gt;?page=&lt;?php echo $pageprev; ?&gt;');" class="pagination_left"&gt;Previous&lt;/a&gt; &lt;?php } else { ?&gt; &lt;div class="pagination_left, page_grey"&gt;Previous&lt;/div&gt; &lt;?php } ?&gt; &lt;div class="pagination_middle"&gt; &lt;?php $numofpages = $totalrows / $limit; if(($totalrows % $limit) != 0) // using this avoids the second for-loop (avoids redundant code) $numofpages++; for($i = 1; $i &lt;= $numofpages; $i++) { if($i == $page) { ?&gt; &lt;div class="page_number_selected"&gt;&lt;?php echo $i; ?&gt;&lt;/div&gt; &lt;?php } else { ?&gt; &lt;a href="javascript: change('&lt;?php echo $area; ?&gt;', '&lt;?php echo $prc; ?&gt;?page=&lt;?php echo $i; ?&gt;');" class="page_number"&gt;&lt;?php echo $i; ?&gt;&lt;/a&gt; &lt;?php } } ?&gt; &lt;/div&gt; &lt;?php if(($totalrows - ($limit * $page)) &gt; 0) { $pagenext = $page+1; ?&gt; &lt;a href="javascript: change('&lt;?php echo $area; ?&gt;', '&lt;?php echo $prc; ?&gt;?page=&lt;?php echo $pagenext; ?&gt;');" class="pagination_right"&gt;Next&lt;/a&gt; &lt;?php } else { ?&gt; &lt;div class="pagination_right, page_grey"&gt;Next&lt;/div&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--&gt; &lt;!--// END PAGINATION--&gt; &lt;!--///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////--&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload