Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2008, 01:39 PM
prislea prislea is offline
 
Join Date: May 2008
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default vbadvanced page

Hi,

I've made a php page for vbadvanced, it is a dictionary and the code look like this:

Code:
<?php

error_reporting(E_ALL & ~E_NOTICE);

define ('NO_REGISTER_GLOBALS', 1);
define ('THIS_SCRIPT', 'dictionar');
require_once('./global.php');

$rowsPerPage = 30;
$pageNum = 1;
$inx = 0;
if(isset($_GET['page']))
{
    $pageNum = $_GET['page'];
}

$offset = ($pageNum - 1) * $rowsPerPage;


    echo "<tr><td class=\"alt2\">"
	 ."<div align=\"center\">"
	 ."<form action=\"index.php?pageid=dictionar\" method=\"post\">"
	 .$vbphrase['dic_find'].":"
	 ."<input type=\"text\" name=\"dicSearch\" size=\"26\">"
	 ."<select name=\"searchType\">"
	 ."<option selected value=\"exact\">".$vbphrase['dic_exact']."</option>"
	 ."<option value=\"starts_with\">".$vbphrase['dic_starts']."</option>"
	 ."<option value=\"ends_with\">".$vbphrase['dic_ends']."</option>"
	 ."<option value=\"contains\">".$vbphrase['dic_contains']."</option>"
	 ."</select>"
	 ."<input type=Submit value=\"".$vbphrase['dic_search']."\">"
	 ."</form>"
	 ."</div>"
	 ."<br />";

$dicSearch = $_POST['dicSearch'];
$searchType = $_POST['searchType'];

$searchTypeText = "='$dicSearch'";

if($searchType == "starts_with") {
	$searchTypeText = " like '$dicSearch%'";
}
else if($searchType == "ends_with") {
	$searchTypeText = " like '%$dicSearch'";
}
else if($searchType == "contains") {
	$searchTypeText = " like '%$dicSearch%'";
}

if($dicSearch != "") {
	
	$resultat = $db->query_read("SELECT * FROM " . TABLE_PREFIX ."dictionar_dictionary WHERE dic_word".$searchTypeText." order by dic_word LIMIT $offset, $rowsPerPage");
		
	while(list($did, $dic_word, $dic_def) = $db->fetch_row($resultat)) {
		echo "<br><strong>$dic_word</strong> <i>$dic_def</i><br>";
		$inx++;
	}
	
	if($inx == 0) {
		echo "<center><strong><i>$dicSearch</i> ".$vbphrase['dic_notfound']."</strong></center>";
	}
	
	echo "<br><center>";
	

	$resultat = $db->query_read("SELECT COUNT(*) AS numrows FROM " . TABLE_PREFIX ."dictionar_dictionary WHERE dic_word".$searchTypeText);
	$row = $db->fetch_array($resultat, MYSQL_ASSOC);
	$numrows = $row['numrows'];
	$maxPage = ceil($numrows/$rowsPerPage);
	$self = $_SERVER['PHP_SELF'];
	$nav = '';

for($page = 1; $page <= $maxPage; $page++)
{
    if($page == $pageNum)
    {
	$nav .= " $page ";
    }
    else
    {
	$nav .= " <a href=\"$self?pageid=dictionar&amp;page=$page\">$page</a> ";
    }
}

if ($pageNum > 1)
{
    $page = $pageNum - 1;
    $prev = " <a href=\"$self?pageid=dictionar&amp;page=$page\">[".$vbphrase['dic_previous']."]</a> ";
    $first = " <a href=\"$self?pageid=dictionar&amp;page=1\">[".$vbphrase['dic_first']."]</a> ";
}
else
{
    $prev = '&nbsp;';
    $first= '&nbsp;';
}

if ($pageNum < $maxPage)
{
    $page = $pageNum + 1;
    $next = " <a href=\"$self?pageid=dictionar&amp;page=$page\">[".$vbphrase['dic_next']."]</a> ";
    $last = " <a href=\"$self?pageid=dictionar&amp;page=$maxPage\">[".$vbphrase['dic_last']."]</a> ";
}
else
{
    $next = '&nbsp;';
    $last= '&nbsp;';
}


    echo $first . $prev . $nav . $next . $last;
    echo "</center>";
    echo "<BR>";
} 

    $totaldb = $db->num_rows($db->query_read("SELECT * FROM " . TABLE_PREFIX . "dictionar_dictionary"));
    echo "<div align=\"right\"><FONT class=\"smallfont\" color=\"red\">".$vbphrase['dic_totaldb'].": $totaldb ".$vbphrase['dic_words']."</FONT></div>\n";

    echo "</td></tr>";
?>
everything is working fine until I need to go to the next page. I am a beginner in php and programing in general and I dont know what the problem is.
when I click on the [next] link what looks like this
http://www.mysite.net/index.php?pageid=dictionar&page=2
I get the page without results like the begin page.
Reply With Quote
  #2  
Old 05-30-2008, 02:54 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For help on vbadvanced, you need to go to vbadvanced.com
Reply With Quote
Reply


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 08:50 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.06594 seconds
  • Memory Usage 2,171KB
  • Queries Executed 11 (?)
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_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete