Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Searching a Flat File
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Searching a Flat File

 Post Reply Post Reply Page  12>
Author
wolfie View Drop Down
Groupie
Groupie


Joined: 18 November 2002
Location: United Kingdom
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote wolfie Quote  Post ReplyReply Direct Link To This Post Topic: Searching a Flat File
    Posted: 24 February 2005 at 12:56pm
My website, WolfWeb.zero is made using a flat file system. My flat file system works on one page of ASP that is split up using
if Request.querystring("page") = "thisPage" then
Now, I want to be able to search the file for something and then make the search return the page of the right querystring.

So if the search is "blogs" then it finds a piece of text in a page under the request (ie ("page") = "blogs") and so it returns the URL http://www.wolfweb.co.uk/?page=blogs.

My site also runs of a Access backend, so that the blogs, say, are placed dynamically in the page (just like the Journal on WWG) so the search field needs to be able to do that.

So, using that rough guide as to what I want, can anybody help?

Cheers!
Wolfie--[ WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 10:21pm

Let me see if I get you ... you want to enter some thing and have it come up with that as a querystring ? So if a user enters blogs you want it to go to ?page=blogs ????

If that is the case, its relatively simple to do.
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 12:53am
Assuming you've loaded your file into a string called strFileText something like this should work...
 
strStartFoundWordPos = instr(strFileText,request.querystring("page"))
strLength = Len("
http://www.wolfweb.co.uk/?page=")
strStartPos = strStartFoundWordPos - strLength
strLength = strLength + Len(request.querystring("page"))
 
StrURL = mid(strFileText,strStartPos,strLength)
 
I'm not sure about what else you're trying to do with the access db - e.g. where/when are you going after it after you pull a url.
Not Tested


Edited by dpyers - 28 February 2005 at 12:58am

Lead me not into temptation... I know the short cut, follow me.
Back to Top
wolfie View Drop Down
Groupie
Groupie


Joined: 18 November 2002
Location: United Kingdom
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote wolfie Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 11:43am
Well, here's the code to load up a page.
<% if Request.querystring("page") = "thisPage" then %>
    This is page 1
<% end if
if Request.querystring("page") = "newPage" then %>
    This is a new page
<% end if %>

Wolfie--[ WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 11:44am
or you can uise the elseif command and use

<% if Request.querystring("page") = "thisPage" then %>
    This is page 1
<%
elseif
Request.querystring("page") = "newPage" then %>
    This is a new page
<% end if %>

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 12:23pm
<% if Request.querystring("page") <> "ThisPage" then
   strStartFoundWordPos = instr(strFileText,request.querystring("page"))
   strLength = Len("
http://www.wolfweb.co.uk/?page=")
   strStartPos = strStartFoundWordPos - strLength
   strLength = strLength + Len(request.querystring("page"))
 
   StrURL = mid(strFileText,strStartPos,strLength)
 
   Server.Transfer(StrURL)
 
end if %>
With the above code, if it's not asking for ThisPage, it will pull the proper page info, buld the url, and transfer control to that url.

Lead me not into temptation... I know the short cut, follow me.
Back to Top
wolfie View Drop Down
Groupie
Groupie


Joined: 18 November 2002
Location: United Kingdom
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote wolfie Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2005 at 12:37pm
I'm not picking up how to do this... I rather not put my page in the form of a string, but outside the ASP area. So simple XHTML.

But will this actully search my site (or flat file) for a certain word and then pull up the page? Not just if the word is in the querystring.

(I'm still fairly new to ASP so forgive me!)
Wolfie--[ WolfWeb.co.uk ]
PHP, .net--[ beginner ] ASP, VB, C, SQL--[ intermediate ] X/D/HTML, CSS, WML, XML--[
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 01 March 2005 at 4:37pm
No, I thought you had the words and associated links all in one file so reading it into a string wasn't a big deal.
 
If you want to search the contents of all files on your site you'll need a more expansive script. Check aspin.com or one of the other script sites for a search script.
 
Frontpage also has a search component.

Lead me not into temptation... I know the short cut, follow me.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.