Forum Moderators: coopster
$result = mysql_fetch_array(mysql_query("SELECT CASEACTIVITY FROM ttime WHERE TIMEID = '$TIMEID'"));
$user_val = $result['CASEACTIVITY'];
$query = mysql_query("SELECT * FROM subcaseactivity");
while($array = mysql_fetch_array($query)) {
if($array['id'] == $user_val) {
print "<option selected value=$array[id]>$array[name]</option>";
} else {
print "<option value=$array[id]>$array[name]</option>";
}
}
?>
</select>
if($array['id'] == $user_val) Are you sure that the above comparison is correct? Are you comparing the ID values or the name values?
Without knowing much about your database: IN the rest of your code you reference $array[id] instead of id in the single quotes. Maybe that is a problem.
One way to debug this would be to output the value you are retreiving form the database ($user_val). Try printing that out to the page to see if it is even returning a value.
-=casey=-
$result = mysql_fetch_array(mysql_query("SELECT CASEACTIVITY FROM ttime WHERE TIMEID = '$TIMEID'")); I would guess that it isn't returning any information.
Where do you get $TIMEID from? Try printing out the $TIMEID value like you did for $user_val.
Also, in your sql statement you wrap the $TIMEID in quotes. If this is an integer column then you should not do that.
-=casey=-