this is code diplays everything in one page how can i make this show more then one page?

thak you

// Addon Specific Function
    function viewallusers_display_addon_link() {
        // Show the link for the menu
        $display = '<a href="index.php?action=addon_viewallusers_showpage1">View All Agents</a>';
        return $display;
    }
     
    function viewallusers_display_addon_page() {
        // display all the users in columns, pictures and names
        global $conn, $lang, $config, $style;
        require_once($config['basepath'].'/include/misc.inc.php');
        $misc = new misc();
        $display = '<table border="1" cellspacing="10" cellpadding="3" width="$style[admin_table_width]" class="form_main" align="center">';
        $var_reset = 1; // Reset the var (counter) (DO NOT CHANGE)
        // How Many To show Per Row
        $user_col_max = 4; // Change this to suit your needs
         
        // pull the user information from the table
        $sql = "SELECT userdb_user_name, userdb_id, userdb_user_first_name, userdb_user_last_name FROM " . $config[table_prefix] . "userdb where userdb_is_agent = 'yes' order by userdb_user_name";
        $recordSet1 = $conn->Execute($sql);
        if ($recordSet1 === false) {
            $misc->log_error($sql);
        }
        while (!$recordSet1->EOF) {
            // loop through our users
            $name = $misc->make_db_unsafe ($recordSet1->fields[userdb_user_name]);
            $first = $misc->make_db_unsafe ($recordSet1->fields[userdb_user_first_name]);
            $last = $misc->make_db_unsafe ($recordSet1->fields[userdb_user_last_name]);
            $userID = $misc->make_db_unsafe ($recordSet1->fields[userdb_id]);
            if ($var_reset == 0) {
                $display .= "<tr>";
            }
            $display .= "<td align=\"center\" valign=\"top\"><a href=\"$config[baseurl]/index.php?action=view_user&user=$userID\">";
             
            // get our image data using the userid
            $user = $misc->make_db_unsafe($userID);
            $sql = "SELECT userimages_id, userimages_caption, userimages_file_name, userimages_thumb_file_name FROM " . $config[table_prefix] . "userimages WHERE (userdb_id = $user) ";
            $recordSet = $conn->SelectLimit($sql, 1, 0 );
            if ($recordSet === false) {
                $misc->log_error($sql);
            }
            $num_images = $recordSet->RecordCount();
            if ($num_images > 0) {
               // while (!$recordSet->EOF) {
                    $caption = $misc->make_db_unsafe ($recordSet->fields[userimages_caption]);
                    $thumb_file_name = $misc->make_db_unsafe ($recordSet->fields[userimages_thumb_file_name] );
                    $file_name = $misc->make_db_unsafe ($recordSet->fields[userimages_file_name]);
                    $imageID = $misc->make_db_unsafe ($recordSet->fields[userimages_id]);
                    $imagedata = GetImageSize("$config[user_upload_path]/$thumb_file_name" );
                    $imagewidth = $imagedata[0];
                    $imageheight = $imagedata[1];
                    $shrinkage = $config[thumbnail_width]/$imagewidth;
                    $displaywidth = $imagewidth * $shrinkage;
                    $displayheight = $imageheight * $shrinkage;
                    $display .= "<img src=\"$config[user_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\"><br> ";
                   // $recordSet->MoveNext();
               // }
            } else {
                $display .= "<img src=\"images/nophoto.gif\"><br>";
            }
             
            $display .= "<br>$first $last</a><br>";
            $display .= "</td>";
             
            if ($var_reset == $user_col_max) {
                $display .= "</tr>";
                $var_reset = 1;
            } else {
                $var_reset++;
            }
            $recordSet1->MoveNext();
        } // end While loop
        $display .= "</td></table><br>";
        return $display;
    } // end viewallusers_display_addon_page
     
     
    // Addon Specific Function
    function viewallusers_display_admin_page() {
    }
?>
Member Avatar for diafol

Sorry, I haven't read this in detail, but...

You'll probably need to use the LIMIT clause in your sql. Here's a snippit I use regularly - I've modified it slightly for this post so it's not tested.

$default_records_per_page = 5;

	$current_entries = mysql_query("SELECT * FROM mytable");
	$no_pages = ceil(mysql_num_rows($current_entries)/$default_records_per_page);
	
	
        if(isset($_GET['page'])){
		if(is_numeric($_GET['page'])){
			if($_GET['page'] > $no_pages){
				$page = $no_pages;
			}else{ 
				$page = $_GET['page'];
			}
		}else{
			$page = 1;
		}
	}else{
		$page = 1;
	}

	$from = (($page * $default_records_per_page) - $default_records_per_page);

	$sql = mysql_query("SELECT * FROM mytable LIMIT {$from}, {$default_records_per_page}");
        while($output = mysql_fetch_array($sql)){
	   //show your stuff 
        }

        echo "<div id = \"page_navigation\">";
        if($page > 1){
	       $prev = ($page - 1);
   	       echo "<a  href=\"".$_SERVER['PHP_SELF']."?page=$prev\">&laquo; PREV</a>";
        } 
    
        echo "<p>";
        
        for($i = 1; $i <= $no_pages; $i++){
	       
             if(($page) == $i){
                  echo $i . " ";
             }else{
                  echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
             }
        } 

        echo "</p>";

        if($page < $no_pages){
             $next = ($page + 1);
             echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">NEXT &raquo;</a>";
        }
        echo "</div>";

how would i combine them?

thakn you

Member Avatar for diafol

Sorry mate, haven't got the time to do this for you. Your code is object-orientated - this ain't your code I take it, coz if you could write that, you wouldn't have asked the last question.

I'll give you an idea:

Find a section of code that relates to a single "entity". Find the 'parent' SQL query and apply the LIMIT clause to it.

i don't understand much of coding but thank you for trying.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.