vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   plugin not working? (https://vborg.vbsupport.ru/showthread.php?t=174611)

lukemax 04-02-2008 03:22 PM

1 Attachment(s)
Dismounted, I tried pasting the code into the php page (screenshot) the same place (beneath the START MAIN SCRIPT comment as I believe boofo did (when I looked at his info.php file), is that what u mean, cause its not working for me. I pasted this PHP code at line 37.
PHP Code:

// include MySQL connector function
if (! @include('includes/connection.inc.php')) {
  echo 
'Sorry, page unavailable';
  exit;
  }
$conn dbConnect('query');

// how many rows to show per page
$rowsPerPage 20;

// by default we show first page
$pageNum 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
    
$pageNum $_GET['page'];
}

// counting the offset
$offset = ($pageNum 1) * $rowsPerPage;
$result mysql_query("
    SELECT Approve, ID, Name, featured_pic 
    FROM provider 
     WHERE Approve = '1'
    ORDER BY rand() 
    LIMIT 
$offset$rowsPerPage
    "
);
echo 
"<table width='70%' cellpading=7 border=1 bordercolor='black' rules='rows' align='center'>";
echo 
"<tr><th width='120px' class='tcat'>Thumbnail</th>";
echo 
"<th align='left' class='tcat'>Name</th></tr>";
while (
$row mysql_fetch_array($result))
{
if(empty(
$row['featured_pic'])) {
$thumb_nail "<img src='/images/ASP_Images/thumbs/default.jpg' border='0' />";
} else {
$thumb_nail '<img src="'.$row['featured_pic'].'" alt="'.$row['Name'].'" border="0" />';
}
    
// Build your formatted results here.
    
print '<tr>';
    print 
'<th><a href="/provider_page.php?ID=' .$row['ID']. '">'.$thumb_nail.'</a></th>'
    print 
'<th align=\'left\'><a href="/provider_page.php?ID='.$row['ID'].'" class="link">'.$row['Name'].'</a></td>';
    print 
"</tr>";
    print 
"\n";
}
echo 
"</td></tr></table>";

// how many rows we have in database
$query   "SELECT COUNT(ID) AS numrows FROM provider";
$result  mysql_query($query) or die('Error, query failed');
$row     mysql_fetch_array($resultMYSQL_ASSOC);
$numrows $row['numrows'];

// how many pages we have when using paging?
$maxPage ceil($numrows/$rowsPerPage);

// print the link to access each page
$self $_SERVER['PHP_SELF'];
$nav  '';

for(
$page 1$page <= $maxPage$page++)
{
   if (
$page == $pageNum)
   {
      
$nav .= $page "// no need to create a link to current page
   
}
   else
   {
      
$nav .= " <a href=\"$self?page=$page\">$page</a> ";
   }
}
// creating previous and next link
// plus the link to go straight to
// the first and last page

if ($pageNum 1)
{
   
$page  $pageNum 1;
   
$prev  " <a href=\"$self?page=$page\">[Prev]</a> ";

   
$first " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
   
$prev  '&nbsp;'// we're on page one, don't print previous link
   
$first '&nbsp;'// nor the first page link
}

if (
$pageNum $maxPage)
{
   
$page $pageNum 1;
   
$next " <a href=\"$self?page=$page\">[Next]</a> ";

   
$last " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
   
$next '&nbsp;'// we're on the last page, don't print next link
   
$last '&nbsp;'// nor the last page link
}

// print the navigation link
echo "<p style='text-align:center'>".$first $prev $nav $next $last."</p>"


Dismounted 04-03-2008 04:29 AM

All output needs to be put into one (or more) variables, and used in the template to display. In vBulletin programming, you will not ever use echo, unless you're doing something really special.

lukemax 04-03-2008 03:25 PM

ok, thanks...got it.


All times are GMT. The time now is 06:10 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01779 seconds
  • Memory Usage 1,755KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete