PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
snype
Regular
Regular


Joined: Aug 12, 2008
Posts: 58

PostPosted: Tue Jun 01, 2010 7:49 am Reply with quote Back to top

Hello i wonder if some one could advise me on how i could add pagination to this module?
the code for the index.php is
Code:
<?php

if (!defined('MODULE_FILE')) {
   die('You can\'t access this file directly...');
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
$index = 0;

   include("header.php");
global $db, $prefix, $bgcolor1, $bgcolor3, $bgcolor2, $textcolor1, $module_name;
OpenTable();
echo "<center>\n<table width='100%' cellpadding='2' cellspacing='1' bgcolor='$bgcolor2'>\n";
echo "<tr><td align='center' colspan='4' class='option'><b><font color='gray'>Screencasts</font></b></td></tr>\n";
$result = $db->sql_query("SELECT * from ".$prefix."_screencasts ORDER BY pos ASC");
while($row = $db->sql_fetchrow($result)) {
$rid = intval($row['rid']);
$pos = intval($row['pos']);
$rtitle = $row['rtitle'];
$rimg = $row['rimg'];
$rurl = $row['rurl'];
$furl = $row['furl'];
$rdetails = $row['rdetails'];
$one = $row['one'];
echo "<tr bgcolor='$bgcolor1' align='center'>\n";
echo "<td align='left' colspan='2'><a href='$rurl' class='colorbox'><b>$rtitle</b></a></td><td align='right'><b>Screencast Image</b></td></tr>\n";
echo "<tr bgcolor='$bgcolor1'><td width='100%' colspan='2'>$rdetails<br/><br/><b>Duration</b>&nbsp;$one<br/><br/><a href='$furl'><b>Disscusions Forums</b></a></td>";
echo "<td align='right'><a href='$rurl' class='colorbox'><img src='$rimg' width='150' height='150' /></a></td></tr> ";



echo "<tr><td colspan='2'></td></tr>";
}
echo "</tr></table><br />";
CloseTable();
include("footer.php");


      
      


?>


Snype
View user's profile Send private message
Palbin
Site Admin


Joined: Mar 30, 2006
Posts: 2403
Location: Pennsylvania

PostPosted: Tue Jun 01, 2010 5:08 pm Reply with quote Back to top

I didn't actually test this as I did not have database info, but it should get you very close.

Code:

<?php

if (!defined('MODULE_FILE')) {
   Header('Location: index.php');
   exit('Access Denied');
}

//Number of items per page
$perpage = 10;

if (isset($_GET['pagenum'])) {
   $pagenum = abs(intval($_GET['pagenum']));
   $min = $perpage * ($pagenum - 1);
   $max = $min + $perpage;
} else {
   $min = 0;
   $max = $perpage;
}

require_once 'mainfile.php';
$module_name = basename(dirname(__FILE__));

$index = 0;
if (!defined('INDEX_FILE')) define('INDEX_FILE', false); // Set to FALSE to hide right blocks
if (defined('INDEX_FILE') AND INDEX_FILE === true) {
   // auto set right blocks for pre patch 3.1 compatibility
   $index = 1;
}

global $db, $prefix, $bgcolor1, $bgcolor3, $bgcolor2, $textcolor1, $module_name;

$result = $db->sql_query('SELECT * FROM `' . $prefix . '_screencasts` ORDER BY pos ASC');
$totalcasts = $db->sql_numrows($result);
$link = 'modules.php?name=' . $module_name;
$sPaginatorHTML = pagenums($link, $totalcasts, $perpage, $max);

include 'header.php';
OpenTable();
if ($sPaginatorHTML) {
   echo $sPaginatorHTML;
}
echo '<center>' , "\n" , '<table width="100%" cellpadding="2" cellspacing="1" bgcolor="' , $bgcolor2 , '">' , "\n"
   , '<tr><td align="center" colspan="4" class="option"><b><font color="gray">Screencasts</font></b></td></tr>' , "\n";
$result = $db->sql_query('SELECT * FROM `' . $prefix . '_screencasts` ORDER BY pos ASC');
while($row = $db->sql_fetchrow($result, MYSQL_ASSOC)) {
   $rid = intval($row['rid']);
   $pos = intval($row['pos']);
   $rtitle = $row['rtitle'];
   $rimg = $row['rimg'];
   $rurl = $row['rurl'];
   $furl = $row['furl'];
   $rdetails = $row['rdetails'];
   $one = $row['one'];
   echo '<tr bgcolor="' , $bgcolor1 , '" align="center">' , "\n"
      , '<td align="left" colspan="2"><a href="' , $rurl , '" class="colorbox"><b>' , $rtitle , '</b></a></td><td align="right"><b>Screencast Image</b></td></tr>' , "\n"
      , '<tr bgcolor="' , $bgcolor1 , '"><td width="100%" colspan="2">' , $rdetails , '<br /><br /><b>Duration</b>&nbsp;' , $one , '<br /><br /><a href="' , $furl , '"><b>Disscusions Forums</b></a></td>'
      , '<td align="right"><a href="' , $rurl , '" class="colorbox"><img src="' , $rimg , '" width="150" height="150" /></a></td></tr>'
      , '<tr><td colspan="2"></td></tr>';
}
echo '</tr></table><br />';
CloseTable();
include 'footer.php';

function pagenums($link, $totalselected, $perpage, $max) {
   global $pagenum, $cfgPaginatorControl;

   $pagenum = abs(intval($pagenum));
   $usePaginatorControl = true;
   $rowsperpage = $perpage + 1;
   if ($totalselected < $rowsperpage) {
      $usePaginatorControl = false;
   }
   if ($usePaginatorControl) {
      include_once NUKE_CLASSES_DIR . 'class.paginator.php';
      include_once NUKE_CLASSES_DIR . 'class.paginator_html.php';
      $oPaginator = new Paginator_html($pagenum, $totalselected, $perpage);
      $oPaginator->setDefaults($cfgPaginatorControl);
      $oPaginator->set_Limit($perpage);
      $oPaginator->set_Links($cfgPaginatorControl['iMaxPages']);
      $oPaginator->setLink($link);
      $oPaginator->setTotalItems(_PAGINATOR_TOTALSTORIES);
      $sPaginatorHTML = $oPaginator->getPagerHTML() . '<br />';
      return $sPaginatorHTML;
   } else {
      return false;
   }
}

?>
View user's profile Send private message Visit poster's website
snype
Regular
Regular


Joined: Aug 12, 2008
Posts: 58

PostPosted: Tue Jun 01, 2010 7:22 pm Reply with quote Back to top

Palbin Many thanks for the help. And i have sent you a PM

Snype
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum