Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 11th, 2003, 09:04 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
How do I setup query for either keyword or drop down search?

I have a database that I want to be able to search by either keyword or a drop down list. The way it is currently set up on my site, the dropdown category menu searches the category field of my database with one php script, and the keyword search uses a different php script to search the ingredients field of the database.

Can I...
1. Make 1 php script with the (Select FROM etc etc) setup to handle both a keyword and select input, but not at the same time?
or,
2. Use 2 <form action> tags, one for the keyword and one for the drop down select, in one HTML document and still use the 2 separate php scripts?

Any help is appreciated

Reply With Quote
  #2  
Old August 11th, 2003, 11:48 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 4
RE: How do I setup query for either keyword or drop down search?

1. One PHP script:
php Code:
Original - php Code
  1.  
  2. if(isset($_GET['category']))
  3. {
  4.    // search by category
  5. } elseif(isset($_GET['keyword'])) {
  6.    // search by keyword
  7. }


2. Two forms in one HTML file
Code:
<form action="search_script.php" method="get">
<input type="text" name="keyword">
<input type="submit" value="Search by keyword">
</form>
<br>
<form action="search_script.php" method="get">
<select name="category">
   <option value="cat1">Category 1</option>
   <option value="cat2">Category 2</option>
   <option value="cat3">Category 3</option>
</select>
<input type="submit" value="Search by category">
</form>


Reply With Quote
  #3  
Old August 13th, 2003, 03:38 AM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: How do I setup query for either keyword or drop down search?

I tried this setup, and it only partly worked.

1. Do both of the form action tags need to point to the same php script to do the search? I tried them going to separate scripts, and the same script, and only one would work properly at a time.

2. If they both point to the same search script, and I add the php code listed above, then how would I set up the SELECT FROM part of the search script? Each form action searches a different field, so can the SELECT FROM statement query by 2 potentially different search variable passed to it?


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > How do I setup query for either keyword or drop down search?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek