Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 4th, 2007, 08:36 AM
Authorized User
 
Join Date: Dec 2006
Location: , , Sweden.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with search-form

Hi!
Ive got a search-form that I cant get to work the way I want.
It consist of two text-fields and a date-picker(two fields with a start date and a end date).
The problem I have is that I cant get it to work if you enter a criteria in more than one of the fields. Ie I can either search for "food", but not "food"(in the fírst field) and "pizza"(in the second). Can't use the date-picker with any of them. It works if I only use one of the criterias.
Code:
if($nydatum1 != '--' or $nydatum2 != '--')
{
 $sel_sok = mysql_query("SELECT * FROM container WHERE datum BETWEEN '$nydatum1' AND '$nydatum2' OR fraktion LIKE '$_POST[fraktion]' OR ort LIKE '$_POST[ort]'") or die(mysql_error('Fel vid sökning!'));
}
else
{
 $sel_sok = mysql_query("SELECT * FROM container WHERE ort='$_POST[ort]' OR fraktion LIKE '$_POST[fraktion]' OR ort LIKE '$_POST[ort]'") or die(mysql_error('Fel vid sökning!'));
}
Ive made two "SELECT"-lines depending on if the date is set or not, but if I dont need it, Ill drop it for a better solution :)

Thanks in advance!
/Hylsan



Similar Threads
Thread Thread Starter Forum Replies Last Post
Search Form? scandalous Access 8 February 8th, 2007 09:01 AM
Problem opening Form from search sprocket Access 5 July 7th, 2006 01:17 PM
Search in a sub form smang Access 1 January 7th, 2005 08:30 PM
Search Form ksa266 Access VBA 2 December 29th, 2003 06:37 AM
Problem with Search Form DRuiz VB Databases Basics 3 June 6th, 2003 11:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.