Re: mysql's enum type used with php/html form?

From: Date: Wed, 24 May 2000 16:18:22 +0000
Subject: Re: mysql's enum type used with php/html form?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-78@lists.php.net to get a copy of this message
on 5/24/00 6:30 AM, Kenn Murrah at warden@bakergrfx.com wrote: > Good morning. > > I'm having a bit of trouble using a form with > pull-down select menus, then writing the choice > to a mySQL field with a type of "enum." > > Can anyone point me in the direction of a simple > example of this? Once I see the code, I'm sure > I'll slap myself on the forehead, berate myself for > not seeing the obvious, and promise myself that > I'll never ask anything this elementary on the list > again. > > In the meantime, though, I could use any advice > that anyone might have. > > Thanks, > > Kenn Murrah Try something like this (code might have an error, but shows the general idea): <?php if ( !isset($mySubmit) ) { // will get here on first pass through page ?> <form action='this_page.php' method='post'> <select name='pulldown'> <option value='enum1'>Enum 1</option> <option value='enum2'>Enum 2</option> </select> <input type='submit' name='mySubmit' value='Go'> </form> <?php } elseif ( $mySubmit == 'Go' ) { // after clicking "Go" button $query = sprintf("INSERT INTO myTable VALUES (myenum='%s')",$pulldown); $result = mysql_query($db_connection,$query); } ?> Where field 'myenum' has values ('enum1','enum2'). Bryan Lovely bryan@lovelys.com

« previous php.db (#78) next »