Pagination into existing php

Discussion in 'PHP' started by ploppy, Oct 5, 2007.

  1. #1
    hello. I have an existing php file that is an integral part of the framework of website and would like to include pagination within it. You will that it outputs existing results to html page and i would like it to remain this way.

    Here is the exisitng code:

     function ShowMyFiles() {
      
        // vars global configuration
        global $dbConn, $theme_path;
    
        // vars messages
        global $msg;
    
        // vars template
        global $error_msg, $pagination, $files, $owner, $test;
    	
        if ($err) {
          $error_msg = $msg['20191'];
        }
        
        //$links_obj                      = new clsLink;
    	
    
        // get file listing
        $query  = "select title, description, date from idx_reslink where category_id=1 LIMIT 10";
        //$links_obj->query               = $query;
        //$links_obj->table_name          = "idx_users";
       // $links_obj->date_format         = $msg["10151"];
        //$links_obj->max_rows            = 100;
        //$files                           = $links_obj->Display();
    	
    	$query      = "select title, description, date from idx_reslink where category_id=1 LIMIT 10";
        $result     = $dbConn->Execute($query);
        //$files = $result->Fields("url");
    	// $owner = $result->Fields("owner");
    	// $date = $result->Fields("date");
    
        // $files = explode ( " ", $files );
    	
    $test = '';
       for($i = 0;$i < $result->RecordCount(); $i++)
       {
       $date = $result->Fields("date");
       $description = $result->Fields("description");
       $title = $result->Fields("title"); 
       
       $test .= '<table width="100%%"  border="0">
     <tr>
        <td></td>
      </tr>
    </table>
    
    <table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">
    <tr class="tbl_caption_mem">
      <td width="16%"><strong>Date</strong></td>
      <td width="51%"><strong>Description</strong></td>
      <td width="13%"><strong>Date Added</strong></td>
    </tr>
    <tr class="tbl_caption_mem">
      <td valign="top">'.$title.'</td>
      <td valign="top">'.$description.'</td>
      <td valign="top">'.$date.'</td>
      </tr>
    </table>';
    $result->movenext();
    }
    $files = $test;
       DisplayTemplate($theme_path . "cp/pl37-39files.html", "\$files,\$pagination,\$error_msg");
      }
    Code (markup):
    i have tried various options to code this, but my php is just not good enough to accomplish this task. many thanks for your help.
     
    ploppy, Oct 5, 2007 IP
  2. aRo`

    aRo` Peon

    Messages:
    141
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    your can use "LIMIT 0,10" or "LIMIT 10,20" in your query to filter your results.

    if you give a query string to your page you can make this dynamically.
    i hope this is clear enough :)
     
    aRo`, Oct 5, 2007 IP
  3. ploppy

    ploppy Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    sorry aRo`, not with you. could you expand? sorry to be a thicky, but totally new to php, as you can tell :)
     
    ploppy, Oct 5, 2007 IP