When an admin is editing a listing (in the admin-only form, not for normal users), I thought it would be more useful for them to select from a dropdown list of users' names, rather than have to enter a user ID number (which they may not know or understand). In order to do this, I cludged together the following code, which I'm hoping people can use and/or make better.

The addition/change is in /admin/listings_edit.php on line 265 (in version 106) or line 264 (in version 107). The line currently reads:

Code:
<tr><td align="right"><b><?php echo $lang&#91;user_editor_user_number&#93; ?>&#58;</b></td><td align="left"> <input type="text" name="owner" value="<?php echo $edit_owner ?>"></td></tr>
I've replaced it with the following:

Code:
<tr><td align="right"><b><?php echo $lang&#91;user_editor_user_number&#93; ?>&#58;</b></td>
					<td align="left" class="row_main"><select name="owner" size="1">
<?php
// find the name of the agent listed as ID in $edit_owner
		$sql="SELECT user_name FROM UserDB WHERE &#40;ID = '$edit_owner'&#41;";
		$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
		$recordSet = $conn->Execute&#40;$sql&#41;;

		if &#40;$recordSet === false&#41; 
		&#123;
			log_error&#40;$sql&#41;;
		&#125;

//strip slashes so input appears correctly
			$edit_owner_name = make_db_unsafe &#40;$recordSet->fields&#91;user_name&#93;&#41;;

		echo "<option value=\"$edit_owner\">$edit_owner_name</option>";

// fill list with names of all agents
		$sql="SELECT ID, user_name FROM UserDB ORDER BY user_name";
		$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
		$recordSet = $conn->Execute&#40;$sql&#41;;

		if &#40;$recordSet === false&#41; 
		&#123;
			log_error&#40;$sql&#41;;
		&#125;

while &#40;!$recordSet->EOF&#41;
		&#123;
//strip slashes so input appears correctly
			$agent_ID = $recordSet->fields&#91;ID&#93;;
			$agent_name = make_db_unsafe &#40;$recordSet->fields&#91;user_name&#93;&#41;;

			echo "<option value=\"$agent_ID\">$agent_name</option>";

			$recordSet->MoveNext&#40;&#41;;
		&#125; // end while

					echo "</select></TD>"; ?>
					</tr>
I tried to use the coding standards of open-realty here. If someone has a way to simplify this, please let me know.