vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vbadvanced page (https://vborg.vbsupport.ru/showthread.php?t=181016)

prislea 05-30-2008 12:39 PM

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.

Lynne 05-30-2008 01:54 PM

For help on vbadvanced, you need to go to vbadvanced.com


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

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.02981 seconds
  • Memory Usage 1,724KB
  • 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_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete