how to search your own site?

General software, Operating Systems, and Programming discussion.
Everything from software questions, OSes, simple HTML to scripting languages, Perl, PHP, Python, MySQL, VB, C++ etc.
Post Reply
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

how to search your own site?

Post by Immortal »

How do I do it? I have no clue. Say, I search for user Immortal and my profile shows up. On a custom result search page..

I suspect mysql? php? some place I can learn to do it? is there some sort of program or such?

Thanks alot! Thanks tony in advance.. I know he's there somewhere.. :D
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post by TonyT »

If server has php/mysql:
http://www.scriptsearch.com/PHP/Scripts ... Searching/
(note: some scripts do NOT require mysql but use a flatfile instead [text file], which may sufice for samller sites.)

Free service:
http://www.fusionbot.com/
No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.

LRH
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

There is more than one way ot skin this cat - depends a lot on your requirements and how the site is built in the first place.

If you know up front that certain elements are meant to be searched (user profiles), I would probably write them out to a database (with metadata fields in the record) to speed seraching. If I was storing 'articles' I would put the text content in a database as well. The appraoch is to build an index as you add content, making searches very fast. You could add a few lines of code to update the db (with meta keywords) each time you add new content. You could set up a dedicated 'meta-table' that maintains a list of keywords per object. All of your searches could be pointed to this table (even better performance than querying multiple tables)

Databases are better than flat files when you are handling 100+ items - that is a general rule of thumb that has served me quite well. The filesystem (flatfile) method can be really slow as EACH file in your site must potentially be opened and parsed for the search string.
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Thanks a bunch... I'll read up and see if I can do it... Thanks again!
Stu
Regular Member
Posts: 341
Joined: Tue Aug 10, 1999 12:00 am

Post by Stu »

Another route to go, if this is hosted on a *nix machine, would be to use ht://Dig ( http://www.htdig.org/ ). It's been around about ten years, so it's fairly solid.
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Thanks again.. boy... databases eh. I don't think I'll have that many sites but who knows how big it could get...

Thanks a lot for now.. I must go do some more learning.. heh.
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

A database can be a flat file, excel spreadsheet, or a data within a dbms.
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

cyberskye wrote:A database can be a flat file, excel spreadsheet, or a data within a dbms.
Okay... erm.. I'm new at this stuff so forgive my stupid questions.

I've been learning about databases but nothing I can really apply. Where can I learn about simple databses for small websites.. books/websites. Let's say to keep a list of users or group certain users into a certain category. So when one do a query of just 'Art students'.. the website just loads those.

Thanks a bunch. Sorry for my sillly questions...
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

I don't think you've asked any silly questions - I meant to point out that in your reading, the term database could take many forms. A csv file could be a database.

I got a lot out of the second edition of this book - http://www.amazon.com/exec/obidos/ASIN/0672326728/qid=1106186726/sr=2-2/ref=pd_ka_b_2_2/103-2349467-1903009 - it covers php/mysql/linux.

How do users register today? What technologies are you using now? Any scripting languages? Where is this hosted? Do you have mysql or other dbms available?

I think you will need some sort of server side scripting to either open a file and read/write to it, or to insert and then retrieve from a DBMS. I can help you with php code to do either, but first...



Make a list of everything you want to search - then decide how to structure it, then decide how to store/access. Helps me to follow this sequence.

Using your example - define all other objects (besides student, which you listed). For each object, decide how many attributes (student type=art|math|history|etc Maybe studentName=xxx) - get the idea? Think in terms of a spreadsheet...how many columns (attributes) and what are their names? How many rows (students) do you anticipate?

Once you have this it will become much more clear how to handle your requirements.

Skye
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Originally I planned for something smaller but u know me... The more I learn the more I want to do.

I've learnt basic ms sql server, access and currently doing oracle. Nothing with php though. The place I host does allow mysql databases. A friend of mine said he can help me do it with access database where it can open/write/search a file. So if I change anything in the database itself it'll reflect it on the website... sounds neat and I hope he can do it...

There's no registration system. It's kind of like a talent agency where I choose who I want on the site. So it'll be fairly small and probably by last name basis. so the user name will probably be called 'lastname' which should be enough for a unique id. I'll also give each of them a category perhaps... Say this 'lastname' belongs to a certain 'category'.

I don't know... I just have the real basic knowledge but not enough to connect it to the website. What do I need to read/write/search a certain database. Let's say a ms sql database/access database which I can probably make.

Thanks a bunch skye! I'll look at more stuff by myself perhaps... if I need anything else I'll probably post again... thanks for the help. thanks for being patient too.. :)
User avatar
ub3r_n00b
Posts: 2086
Joined: Sun Feb 16, 2003 6:31 pm
Location: Rivendel, East of The Ford of Bruinen

Post by ub3r_n00b »

my friend made a pure DHTML search. Not too sure how he did it - It would be relatively slow and it wouldnt be able to handle large pages however, but it is dooable!

-Preet
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

"DHTML" - the term is used loosely. I imagine db connects were done via javascript (client side - bad idea for many reasons) - either way it was a client side technology. The biggest reason to handle this with server-side script is security.

When you think about it, the server is doing the work here (form handling, database access, build some html dynamically(tables/cells), send to browser). Generally, this is a job for server-side scripting.

Presentation layer stuff - cool animation/graphics - are rendered in the browser, so client-side (flash, javascript, javaApplets) approach is probably best.

So have a look at a server side language. PHP, ASP(VB), JavaServerPages are all good choices. JSP can be tough to learn and is less supported amongst bargain hosts. ASP is cool, but only runs well on windows webservers (evil), so I would recommend PHP. There are SO MANY free tutorials and code walkthroughs out there *and* it runs under almost every OS/WebServer. Makes your code very portable if you change hosts. MySQL seems to be by far the most popular dbms amongst budget hosts. It's pretty easy to change DBMS (connectivity functions can be translated) - and you don't have to touch the rest of your code.

Have fun,

Skye
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Thanks! I'm going to get a book on mysql.. preferably a small one so I can read it without getting tired.

Hopefully I'll be able to do it.... Thanks skye for all the info!
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

NP - may I suggest a book that covers MySQL/web dev? Many choices. The intersection between the webserver, the application server/engine, and the dbms will be very enlightening - probably the best place to start.


Learn the grammar and the vocabulary comes easy ;)

JJ
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post by TonyT »

No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.

LRH
User avatar
mountainman
SG VIP
Posts: 15451
Joined: Tue Dec 26, 2000 12:00 am
Location: Colorado

Post by mountainman »

User avatar
ub3r_n00b
Posts: 2086
Joined: Sun Feb 16, 2003 6:31 pm
Location: Rivendel, East of The Ford of Bruinen

Post by ub3r_n00b »

Well the DHTML search that he wrote basically just searched all of the tags in the document for specific words, i guess in the description part, and then returned the parent node to that tag. Of course he used this for pictures and it would be slow for other uses but it works great for his picture viewer.

-Preet
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Thanks tony and skye.. That's real good

I'll probably get one from a bookstore anyhow... Thanks again... I'm now intrigued.. heh
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

T - we've created a monster ;)

Once bitten....
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

ub3r_n00b wrote:Well the DHTML search that he wrote basically just searched all of the tags in the document for specific words, i guess in the description part, and then returned the parent node to that tag. Of course he used this for pictures and it would be slow for other uses but it works great for his picture viewer.

-Preet

Sure - I wasn't knockin it, just that when you write the search criteria in client-side, then your underlying logic is available to the whole world.

He was probably using the 'meta' tag as his index. Nothing wrong with that, but by reviewing the code, you could get very intimate knowledge of how the site is laid out. Go to his page and 'view source' then search for the word 'meta'

Using files is slower because of disk i/o, but also uses more resources - a file handle must be created (consuming memory) to reference the file. Then the file itself uses more memory, etc. DBMSs were created to overcome these things.

There is a limit to the number of file handles you can have open on a given host at a given time. On budget hosting services, this limit is even lower per-user because the host is almost always shared among several sites...
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post by TonyT »

[quote="cyberskye"]T - we've created a monster ]
lol
...and the bite is not that bad, almost feels good in a quasi-masochistic way!
No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.

LRH
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post by TonyT »

DHTML serach is OK, but all the processing is done client side, thus the speed of the serach is limited by the clients computer power, the efficiency of the javascript code, the amount of video memory, the browser security settings. If have XP SP2, this type of search will not function locally on pages one is developing because by defauly active content is restricted from running locally. One must adjust the browser settings.
No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.

LRH
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Okay okay... I created a mysql database at tests.aceryerson.com

how do I populate or create a database to put something there.. so I can try some sql... you know with fields and such.

It allows... Select Insert Update Delete Create Drop Index Alter as it says but how do I actually put something in it?

I'm soo new.. :( sorry and thanks. I read something about phpMyAdmin but I don't have that...
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post by TonyT »

Immortal wrote:Okay okay... I created a mysql database at tests.aceryerson.com

how do I populate or create a database to put something there.. so I can try some sql... you know with fields and such.

It allows... Select Insert Update Delete Create Drop Index Alter as it says but how do I actually put something in it?

I'm soo new.. :( sorry and thanks. I read something about phpMyAdmin but I don't have that...
Exactly how did you create the db? using a control panel or direct sql commands? Many hosts provide a browser interface to create the db, tables & fields. phpMydmin http://www.phpmyadmin.net/

Otherwise, you must create the db, tables, fields etc using a secure shell (command line) with mysql commands, or else use a php script that loads in the browser with forms to create what you want.

The easy part is just creating the db, tables & fields. The tricky part is determining exactly what tables & fields you need. It gets complex with multiple tables and then associating the fields in tables with fields in another table.

Example basic with sql commands:
(this is my phone book)

Code: Select all

CREATE TABLE contacts (
  emailID tinyint(3) unsigned NOT NULL auto_increment,
  firstName char(20) NOT NULL default '',
  lastName char(20) NOT NULL default '',
  eMail char(48) NOT NULL default '" "',
  street char(48) NOT NULL default '" "',
  city char(48) NOT NULL default '" "',
  state char(2) NOT NULL default '"',
  zip char(10) NOT NULL default '" "',
  homePhone char(18) NOT NULL default '" "',
  workPhone char(22) NOT NULL default '" "',
  cellPhone char(18) NOT NULL default '" "',
  companyName char(48) NOT NULL default '" "',
  PRIMARY KEY  (emailID)
) TYPE=MyISAM]To get John Doe's details I would use:[/b]

SELECT * FROM Contacts WHERE lastName = Doe

(* select ALL fields in the table)

No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.

LRH
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Well what do u know.. my host does have myphpadmin and I spent 30 min trying to install one.. (grumbles)

It didn't activate because my database was old and they recently just upgraded..

Time for fun.. :) Thanks tony
User avatar
TonyT
SG VIP
Posts: 10356
Joined: Fri Jan 28, 2000 12:00 am
Location: Fairfax, VA

Post by TonyT »

Immortal wrote:Well what do u know.. my host does have myphpadmin and I spent 30 min trying to install one.. (grumbles)

It didn't activate because my database was old and they recently just upgraded..

Time for fun.. :) Thanks tony
Well, then create a new db using phpmyadmin, a test db. Try it with different setups and eventually use the one that suits you best. Phpmyadmin has an export feature where you can download the actual sql commands, structure & stored data in a .SQL text file, it looks just like what I posted above. This is good for backups and also you can just rename the db and import it back into phpmyadmin and you new real db will get created, structured and populated with data.

I don't understand why phpmyadmin says your existing db is too old. Is this a unix server(linux) or windows server w/ MSSQL?
No one has any right to force data on you
and command you to believe it or else.
If it is not true for you, it isn't true.

LRH
cyberskye
Senior Member
Posts: 4717
Joined: Wed Jan 10, 2001 12:00 am
Location: DC

Post by cyberskye »

Could be that deprecated datatypes were used to build the 'old' one - something along those lines.
anything is possible - nothing is free

:wth:
Blisster wrote:It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)
:wth:
User avatar
Immortal
Posts: 22674
Joined: Tue Apr 11, 2000 12:00 pm
Location: Mississauga, Ontario , Canada. Behaviour : Good

Post by Immortal »

Oh it didn't say it's too old.. it jus didn't even know it existed. I created that database before my host implemented/upgraded the system. Maybe it didn't detect it or anything..

There wasn't anything in the old database anyhow.. I was fooling around with it too. Now I can make fields and all that... Seems like it's going to be fun :)

Thanks
Post Reply