View Single Post
  #3 (permalink)  
Old 07-31-2008, 10:31 PM
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 249
Quote:
Originally Posted by curtiss View Post
Please keep in mind that I have not used or tested the code you provided, so I am only going on what I can see from reading the code.

However, it appears that you will need to run the sql query and retrieve the recordset array before instantiating the classes.

The fetchPagedRow function does not accept any parameters, so there is no point in trying to call it with your SQL query.

I think what you need to do is something like:
PHP Code:
if($result mysql_query($query)) {
$tmparr = array();
while(
$rs mysql_fetch_assoc($result)) {
$tmparr[] = $rs;
}
}
$page $_GET['page'];
$pagedResults = new Paginated($tmparr,10,$page);
while(
$row $pagedResults->getPagedRow()) { 
Oh so there has to be 2 while loops?
In my previous attempt I used two while loops which worked but for other reasons and the difficulty to understand the whole thing I decided to start from scratch:
PHP Code:
   $result mysql_query($query);
   if(
$result){
      while(
$row mysql_fetch_assoc($result)){
          
$booktitlesarray[] = "\t\t\t<span class='goToBookChapter' style='font-weight: bold; color: black;'>".$row['book_title']." ".$row['chapter'].":".$row['verse']."</span><br />\n\n\t\t\t".$row['text_data'];
      }
   }
   return 
$booktitlesarray;


    
//$names = bookTitles(); 

    
$page $_GET['page'];
    
$queryVars $newSearchTheseArr;
    echo 
"<span style='font-weight: bold; color: black;'>".$queryVars."</span><br />\n";
    
//constructor takes three parameters
    //1. array to be paged
    //2. number of results per page (optional parameter. Default is 10)
    //3. the current page (optional parameter. Default  is 1)
    //$pagedResults = new Paginated($names, 10, $page);
    
$pagedResults = new Paginated(bookTitles($searchTheseArr), 10$page);
    echo 
"<div>\n";
    while(
$row $pagedResults->fetchPagedRow()){
        echo 
"\t\t<span>\n{$row}\n\t\t</span><br />\n";
    }
    echo 
"</div>\n";
    
mysql_close($con);
    
//important to set the strategy to be used before a call to fetchPagedNavigation
    
$pagedResults->setLayout(new DoubleBarLayout());
    echo 
$pagedResults->fetchPagedNavigation(); 
__________________
Gilgal's website:
Wheel Of God
Now easy to post scripture verses!
Portfolio

Last edited by gilgalbiblewhee; 07-31-2008 at 10:45 PM.
Reply With Quote