Hi,

This is more of a jsp/html/javascript issue.
It is relatively easy to create a small procedure/function in javascript/jsp
which checks all the fields are not emtpy, and gives a warning message when
you click on the submit button.

Its much easier to run the validation before sending the requests off to
mysql so the query will be simpler, and therefore execute much faster.

Andrew Murphy


-----Original Message-----
From: BadgerBay [mailto:[EMAIL PROTECTED]]
Sent: 27 October 2001 6:00 am
To: [EMAIL PROTECTED]
Subject: Simple problem: Blank search box returns all records


How do I avoid search problems when a user leaves a search box empty on an
Ultradev search page running jserv and attached to a MySQL database?

I have three search boxes: Author, Title, and Keyword
The user enters the search data into one, two, or all three of the fields,
and presses "SUBMIT"

(I use JSP), so the variables for the recordset are (ex. Author) :

Name: varAuthor
Default Value: %   [I also tried 1 ]
Run-Time Value: request.getParameter("txtAuthor")

The search uses this SQL logic:

SELECT Author, Title, Keyword
FROM tbJose
WHERE Author LIKE '%varAuthor%' OR Title LIKE '%varTitle%' OR Keyword LIKE
'%varKeyword%';

The search works perfectly , UNLESS A USER LEAVES ONE BOX EMPTY, then the
search RETURNS ALL RECORDS IN THE DATABASE,
whether the default value is % or is 1.

I do not want this to happen.
How might I modify the code? I am a SQL beginner so I need explicit
instructions.



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to