...

View Full Version : Is there more to searching a website than just the Javascript?



Squishy435
06-08-2010, 06:34 PM
Hi all - I'm designing a website, and I need to have a search button allow users to search the inventory that is on the website. I'm not quite sure what code I'm going to use for the search button, but I imagine that I can work on that sometime.. Along with the code, am I required to have something such as a MySQL database set-up or something of the sort?

This question may be mis-categorized, so please let me know if it is.

Thanks everyone!

cjsingsaas
06-08-2010, 06:38 PM
Any easy options is to use Google's custom search on your page. Easy to implement - and will give you the functionality you're looking for.


Google's CSE (http://www.google.com/cse/)

jfreak53
06-08-2010, 07:45 PM
True, if you aren't using a CMS system or something else like a blog or ecommerce solution that already includes it, Google would be easy to get working.

But if you want to make your own solution, then it would all depend on what your searching, let's start there.

What is it that your searching through? You can't come to the tech until you know what your data is and where it's stored.

So second question, what data is it? Where is it stored at, MySQL DB, XML, or plain text file?

Without this you cannot go from there.

I'm not a JS guy but I'm pretty sure I wouldn't use IT directly to do the search. If for instance it was all stored in a mysql DB I would use SQL to search the DB then just send back to the page the results, very simple. That's what most search things do since most items that are search for are stored in a DB.

Now if it's stored in an XML file then yes I might use JS since I'm not good at XML in PHP or anything else. I think it would just be a matter of reading the things to be searched into an array then searching that array with a regex function. I think, but I'm not an XML guy.

But first things first, answer those previous questions and we find the best solution for you. Unless you went with Google.

Squishy435
06-08-2010, 08:03 PM
True, if you aren't using a CMS system or something else like a blog or ecommerce solution that already includes it, Google would be easy to get working.

But if you want to make your own solution, then it would all depend on what your searching, let's start there.

What is it that your searching through? You can't come to the tech until you know what your data is and where it's stored.

So second question, what data is it? Where is it stored at, MySQL DB, XML, or plain text file?

Without this you cannot go from there.

I'm not a JS guy but I'm pretty sure I wouldn't use IT directly to do the search. If for instance it was all stored in a mysql DB I would use SQL to search the DB then just send back to the page the results, very simple. That's what most search things do since most items that are search for are stored in a DB.

Now if it's stored in an XML file then yes I might use JS since I'm not good at XML in PHP or anything else. I think it would just be a matter of reading the things to be searched into an array then searching that array with a regex function. I think, but I'm not an XML guy.

But first things first, answer those previous questions and we find the best solution for you. Unless you went with Google.

Well, all of the data would just be in a plain text file, basically. I want a user to be able to search through the list of inventory that we have - books, mainly. However, I want them to be able to search by 3 variables: price, genre/category, and keyword.

I'm not sure if I should set up some kind of database! I imagine that would be helpful in organizing the inventory, but would it be needed for the user to be able to search?

Squishy435
06-08-2010, 08:04 PM
Oh - and I did try Google, but that's definitely not for me.. It was a great suggestion though!

jfreak53
06-09-2010, 12:56 AM
Wow flat text file WOW! ha ha

I suggest yes, 100% use a DB! There is no easy way to do that in a plain flat text file, only other thing you could use would be XML.

For a text file be it in JS or PHP that you search with you would have to itterate through all the text file and read each line into an array, then search that array. You would have to do that for searching and for displaying, ewwwww.

Why would you do it that way when you can use a DB like MySQL or PGSQL?

Then all your data is organized in a table with columns and it is sorted. Use MySQL man, and grab it all with PHP or another server side language. Then you can search it very simple like. A quick search in MySQL would be like this:


SELECT * FROM table_name WHERE column LIKE '%search_text%'

That simple little line of code says this. Select all items from the table named "table_name" where the column named "column" has text in it that matches "search_text". It will only send you the items in the table that have that text somewhere in that column. Very quick and simple.

So in short, learn a SSI language and learn SQL, then save your info in a MySQL DB. Or easier, hire someone to do this for you. It's pretty easy shouldn't be too expensive. Heck let me know I could do it for you if you want to hire it out.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum