Re: [PHP4BETA] re:Enum type in MySQl

From: Date: Thu, 13 Jan 2000 05:18:23 +0000
Subject: Re: [PHP4BETA] re:Enum type in MySQl
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-9093@lists.php.net to get a copy of this message
On 13 Jan, Joseph H Blythe wrote: > Allen Lee wrote: > >> look at the mysql select function find_in_set(). >> >> An enum field only lets in the things that were planned. >> once they are in, select * from table where enum_field = 'No' >> will work >> > > Thanks Allen, > > I am really confused now! > > SELECT FIND_IN_SET('N','Y,N'); > > will return 2 > > so... > > $details=mysql_query("SELECT * FROM table_name WHERE > field_name=FIND_IN_SET('N','Y,N')"); > > while ( $details == '2' ) { > > mysql_fetch_row($details); > > $var1=$row[0]; > $var2=$row[0]; > ... > } > > this doesn't seem to do what i would want though I need the fetch row details > to point to the field_name == 'N' not the result which is 2 Huh? I think you may have forgotten that what mysql_query returns is 'a positive reult identifier on success, or false on error' NOT the values of the records found. So the odds of $details being 2 are not dependent on the values found, rather whether the query was successful. So I think what you want issomething like (warning - untested) $result = mysql_query("SELECT * FROM table_name WHERE field_name=FIND_IN_SET('N','Y,N')"); while($row = mysql_fetch_row($results)): $var1=$row[0]; $var2=$row[0]; ... endwhile; > I basically want to grab all the rows which have the field_name == 'N' and > echo them into tables, I had this working quite fine when I just manually set > a char(1) to Y or N Default N but I thought a enum would be a little easier > to manage and a little less problematic. > > Thanks, > > > Joseph H Blythe > > mailto:joe.blythe@binarylogic.com.au > Web Developer > > Binary Logic > 257 Churchill Road, Prospect > Adelaide, South Australia, 5034 > PH:(08)83420022 FAX:(08)83420155 Cheers -- David Robley WEBMASTER | Phone +61 8 8374 0970 RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA Visit the PHP mirror at http://au.php.net:81/ <<<<<<<<<<<<< WARNING * END OF TEXT * STOP READING HERE >>>>>>>>>>>>>>

« previous php.version4 (#9093) next »