AllExperts > DHTML 
Search      
DHTML
Volunteer
Answers to thousands of questions
 Home · More DHTML Questions · Answer Library  · Encyclopedia ·
More DHTML Answers
Question Library

Ask a question about DHTML
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Andrew Hoffman
Expertise
I can field just about any question within this topic ranging from JavaScript to CSS, the two ingredients of DHTML. I`m very interested in the W3C and its validation rules for HTML, XHTML, and CSS, and enjoy answering questions of this type as well. I detest sleep and respond at all hours of the day or night.


Experience
Experience in the area
I've been working with DHTML and CSS for 7 years now and build/maintain websites of my own that implement DHTML navigation.

What I'm doing now
My contract with Microsoft has ended and I am working for myself once again. Please contact me for any front-end work at antibland@gmail.com

 
   

You are here:  Experts > Computing/Technology > HTML/XML > DHTML > searching.....

DHTML - searching.....


Expert: Andrew Hoffman - 7/30/2007

Question
Hi Andrew,
OK... you know how you can go to a realtor website and do a search for exactly what you want?
I need some code to do that. I need a search form on my index page and I need to know where to put keywords I'm supposed to put on each individual page that will bring up those pages as results. Does this make any sense to you?
I've very good with HTML, but only familiar with javascript (i'm a cut and paste and edit... I can't code it myself).. I've searched dynamicdrive.com and can't find what I'm looking for.. maybe this code is not javascript, maybe it's c++?? I don't know... anyway, I think it's an if then code... anyway, any help you can give me would be great.

Thanks,
Christina

Answer
Hi Christina-

JavaScript or HTML cannot help you at all for this question.  C++ is not really the right way either.  You should use a server-side language like PHP or ASP for this.  Basically, you'll have a database containing all the locations, prices, etc., that represent the objects people are searching for.  You may offer people an ability to run searches that translate to English questions like this:

"Show me all homes in California under $120,000."

So your users will fill in an HTML form you create, where the action attribute in the form will point to some server-side processing file.  We'll call this file process.php, if you choose to go the PHP route.  You're basically passing this file different parameters sent in by your user.  PHP gathers the users answers like this:

$some_variable = $_POST['location'];

In this case, '$some_variable' will contain whatever value was selected by the user; this might be a select box.

<select name='location'>
<option>CA</option>
<option>PA</option>
<option>etc.</option>
</select>

Once you have the user's selection, you'll build a query and "ask" the database for a recordset of answers.  The query might look something like this:

"SELECT * from properties where price < 120000 AND location = 'CA'";

That might answer this query:

"Show me all homes in California under $120,000."

Do you see yet how there is no way you could build enough if/then statements to satisfy every possible user question?  You would need a high-powered computer to compute all the possible questions that could be asked; this could reach well into the billions of possibilities.  That's why we have relational databases to make arriving at specific results much less time-consuming.

I understand this is a very shallow tutorial on server-side processing and doesn't exactly answer your question(s).  However, this AllExperts section is really for DHTML, a completely client-side endeavor, so my answer could be worse.  Google around for beginning server-side processing tutorials.  There are some nice ones out there.  I recommend the following URLs:

http://www.keithjbrown.co.uk/vworks/php/php_p1.php
http://www.freewebmasterhelp.com/tutorials/phpmysql

If you get stuck, try asking a question in our PHP section.

Best of luck,
Andrew  

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.