Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 2000051

Re: [PHP3] select and ENUMs From: curt (curtpdx <email protected>)
Date: 05/15/00

Sorry for the omission of the $ ; crummy typing. I figured it out this
afternoon, I think. I set a dummy default value of '1' for the ENUMs, then
changed the script to read as shown below rather that having it the same as
the fill-in-the-blanks columns. I'm a little suspicious, but it seems to
work. By the way, I wouldn't mind at all if it's pointed out to me that
the code's ridiculous; just tag on a solution at the end. Thanks for
everyone's help.

curt
------------------------
Here's the change:

mysql> CREATE TABLE books(
bookid SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
title CHAR(30),
publisher CHAR(30),
isbn CHAR(15),
first_ed ENUM('1', 'y', 'n', 'p'),
signed ENUM('1', 'n', 'y'),

The SELECT statement, with a few 'if' statements removed:

  $searchstmt = "SELECT * FROM books WHERE " ;

  if ($bookid)
     $searchstmt .= "bookid like '%$bookid%' and " ;
  if ($title)
     $searchstmt .= "title like '%$title%' and " ;
  if ($publisher)
     $searchstmt .= "publisher like '%$publisher%' and " ;

  if (first_ed <>
'1') // ENUMs start
here
  {
     $searchstmt .= "first_ed like '%$first_ed%' and " ;
     } else

  if ($signed <> '1')
  {
     $searchstmt .= "signed like '%$signed%' and " ;
      } else
    .
    .
    .
    .$stmt= substr($searchstmt, 0, strlen($searchstmt)-4) ;

Paul Burney wrote:

> Is this the actual code? If so the problem may be that you left off the
> $ in front of the enum.
>
> > if (first_ed)
> ^^
> > $searchstmt .= "first_ed like '%$first_ed%' and "
>
> Hope it helps,
>
> Paul
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Paul Burney
> Webmaster and Internet Developer
> Educational Technology Unit
> Graduate School of Education and Information Studies
> University of California, Los Angeles
> (310) 825-8365
> <webmaster <email protected>>
> <http://www.gseis.ucla.edu/>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>