I have a little PHP situation that maybe someone might have a quick answer for, if not, no worries (I'll just keep googling it). I am trying to return a ENUM value from a mysql db (via PHP) by the key instead of the value.
Here's my code
//connect to the database (three levels up, out of html root for security
require_once('../../../connect_mdjboard.php');
//setup the mysql query
$query = "SELECT relocate FROM candidate WHERE candidate_id='{$SESSION['candidate_id']}'";
//run the query
$result = mysql_query($query);
//strore result as an array in $POST
$POST = mysql_fetch_array($result, MYSQL_ASSOC);
//display relocate (currently displays as value instead of key. I want it return an integer representing the value)
echo $POST['relocate'];
Where mysql contains a field called relocate which is of type ENUM and has the following values: NA, Yes, No. The output of this code is Yes, but I want it to output the key of yes, which is 2. Any ideas?
-azphpdude