phpMyViews - Tutorial

Browsing feature

phpMyViews can split large SELECT results onto different pages and add browsing links to your HTML code only by adding a special LIMIT statement and inserting a special HTML tag!

Just define a SELECT statement like this one (notice the LIMIT command):

SELECT * FROM table1 LIMIT $start,10

Check your syntax: Don't leave spaces after "$start" and only leave one space before "$start".

Now, phpMyViews uses $start as an URL parameter for setting the offset of the LIMIT statement. Just try it

But before you can see anything, you have to include a special tag in the PRE or POST statement: <pmv:browse />

phpMyViews replaces this tag with short browsing links for switching pages. That's it! Isn't it easy ?

Example 2 : Easy browsing

Here is a short example where we use $from as the parameter and 8 datarows on each page:


<?php
  
# MySQL Parameters
  
$pmv_db_host="host";
  
$pmv_db_name="db";
  
$pmv_db_user="user";
  
$pmv_db_pass="pass";
  if (
file_exists('pmv_db_config.php')) {
    include(
'pmv_db_config.php');
  }

  
# Actions
  
$pmv['default'][0]['sql']='SELECT * FROM addresses ORDER BY surname LIMIT $from,2';
  
$pmv['default'][0]['pre']='<table>
        <tr><th>Name</th><th>Address</th><th>Telephone</th></tr>'
;
  
$pmv['default'][0]['main']='<tr><td>$surname, $prename</td><td>$address</td><td>$telephone</td></tr>';
  
$pmv['default'][0]['post']='</table><pmv:browse />';

  
# execute phpMyViews
  //$path_to_pmv=$_SERVER['DOCUMENT_ROOT']."/phpmyviews.php";
  
$path_to_pmv="phpmyviews.php";
  include(
$path_to_pmv);
?>


Previous page Next page
SourceForge.net Logo