Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #21  
Old 04-02-2008, 04:22 PM
lukemax lukemax is offline
 
Join Date: Oct 2006
Posts: 83
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>"
Attached Images
File Type: jpg screen.jpg (66.5 KB, 0 views)
Reply With Quote
  #22  
Old 04-03-2008, 05:29 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #23  
Old 04-03-2008, 04:25 PM
lukemax lukemax is offline
 
Join Date: Oct 2006
Posts: 83
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, thanks...got it.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:13 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03862 seconds
  • Memory Usage 2,229KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (1)postbit_attachment
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete