Categories > TinyButStrong general >

Trying to use a searchstring query with TBS Navigation...help me please.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Shawn
Date: 2004-12-27
Time: 09:34

Trying to use a searchstring query with TBS Navigation...help me please.

Trying to use a searchstring query with my the TBS navigation.  Here's what I have, but can't get it to work right.  I can get results for the first page, but the searchstring isn't passed on to the following pages and they are coming up blank.

<a href="[var..script_name]?PageNum=[nv.next;endpoint;magnet=a;mtype=m+m]">&gt;</a>

Then I tried this

<a href="[var..script_name]?PageNum=[nv.next;endpoint;magnet=a;mtype=m+m]&searchstring=$searchstring">&gt;</a>

That doesn't work.

BUT.

If I type this in the browser it will work.

What am I doing wrong?   Sorry, I'm a newbie.  Has me confused.

Thank you.
By: Skrol29
Date: 2004-12-27
Time: 19:04

Re: Trying to use a searchstring query with TBS Navigation...help me please.

What is your PHP code to merge the navigation bar?
I suppose that the name of the script running this template is search.php, is that correct?
By: Shawn
Date: 2004-12-28
Time: 01:31

Re: Trying to use a searchstring query with TBS Navigation...help me please.

Here's my PHP code.

<?
if ($searchstring)
{
include_once('tbs_class.php') ;

$softwarecode = PageNum;

//Connexion to the database
if (!isset($_SERVER)) $_SERVER=&$HTTP_SERVER_VARS ; //PHP<4.1.0
require($_SERVER['DOCUMENT_ROOT'].'/cnx_mysql.php');

//Default value
if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['PageNum'])) {
  $PageNum = $_GET['PageNum'] ;
} else {
    $PageNum = 1 ;
}

//Default value
if (isset($_GET['RecCnt'])) {
  $RecCnt = intval($_GET['RecCnt']) ;
} else {
    $RecCnt = -1 ;
}

$PageSize = 10 ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate('exe-search.html') ;
//$sql="SELECT * FROM personnel WHERE $searchtype LIKE '%$searchstring%' ORDER BY firstname ASC";
$RecCnt = $TBS->MergeBlock('b1',$cnx_id,"SELECT * FROM titles WHERE keywords LIKE '%$searchstring%' AND approve='Y' ORDER BY softwaretitle ASC",$PageSize,$PageNum,$RecCnt) ;

$TBS->MergeNavigationBar('nv','',$PageNum,$RecCnt,$PageSize) ;
//
//$tpl->Render = TBS_OUTPUT ;
//
$TBS->Show() ;
}
?>

Actually, the name of the php file is exe-search.php  The template file is exe-search.html.  I have a search box on each page.

Looking forward to your help and input.  Thanks.

Sincerely,

Shawn

exefiles.com is the domain if you want to see what I'm talking about.  Thanks.

By: Skrol29
Date: 2004-12-28
Time: 13:16

Re: Trying to use a searchstring query with TBS Navigation...help me please.

Hello Shawn,

I've seen your template at your web site (very well done).
Links on the navigation bar doesn't display anything because the $searchstring variable is lost.

You have to found a way to recall the variable $searchstring. It can be in the URL, through a Html Form, a using cookies or session.
You can also recall the variable $RecCnt which needs to be calculated only once per search. For other pages it can be recalled instead of recalculated.
By: Shawn
Date: 2004-12-28
Time: 16:16

Re: Trying to use a searchstring query with TBS Navigation...help me please.

Thank you for the kind words.  I will give your suggestion a shot and see what I can figure out.  I'll update you.  Thank you.

TBS is fantastic.

By: Shawn
Date: 2004-12-28
Time: 17:04

Re: Trying to use a searchstring query with TBS Navigation...help me please.

How would I code this so I don't lose the search variable?
By: Skrol29
Date: 2004-12-28
Time: 18:38

Re: Trying to use a searchstring query with TBS Navigation...help me please.

As I said, you can use several technics.
- Save $searchstring into cookies, but you won't be able to perform 2 different searches in 2 windows at the same times.
- Save into session => quite the same problem.
- Using a Form. The links in the navigation bar has to activate a Javascript function that update a field with the page number and submit the form. Smart but you need to know Javascript.
- Using the URL. Try something like:
<a href="[var..script_name]?PageNum=[nv.next;endpoint;magnet=a;mtype=m+m]&searchstring=[var.searchstring]&RecCnt=[var.RecCnt]"> &gt;
</a>
And you'll need to change your script in order to retrieve $searchstring if it exists in $_GET. Quite the same code as for $PageNum.
By: Shawn
Date: 2004-12-28
Time: 23:55

Re: Trying to use a searchstring query with TBS Navigation...help me please.

Skrol29,

Again.  With your input I achieved what I set out do accomplish.  Thank you sir.  You provide amazing support, for an amazing script.  I very much appreciate what you do.  Thank you.

Sincerely,

Shawn