动态PHP / mysql下拉菜单问题[重复]

This question already has an answer here:

I can't seem to get this to work. Part of a $_POST.

<?
foreach ($db->query("SELECT * FROM clients WHERE TID = '".$_SESSION['UID']."'") as $row) 

{
echo '<option value=\" '.$row['UID'].' \">'.$row['FNAME'].' '.$row['LNAME'].'</option>';
}?>
</select>

The _POST'ed value for ['UID'] keeps coming up as \"

Tearing my hair out on this one, can't see what must be a very simple error. FNAME and LNAME appearing ok, echoing [UID] on this page shows the right value so it is something here that is wrong.

</div>

Your query is going to return a result set, not an array. You have to get the result set, THEN extract the data

$vals = $db->query("SELECT * FROM clients WHERE TID = '".$_SESSION['UID']."'");
while( $row = $vals->fetch_assoc()) {
    echo '<option value="' . $row['UID'] . '">' . $row['FNAME'] . ' ' . $row['LNAME'] . '</option>';
}

You don't need to slash double quotes here, as you're declaring strings in single quotes.

i.e., try:

echo '<option value="'.$row['UID'].'">'.$row['FNAME'].' '.$row['LNAME'].'</option>';