Select list not populating

Hello all,
I am relatively new to PHP so please bear with me. I have a site that I am rewriting from Coldfusion to PHP because I like PHP better and I am tired of using ColdFusion. Anyway, everything is going well except for this stupid select list that is not populating. Here is my code below:
First, I query a table that joins two other tables together. If there is a result (there will be ONLY one result if there is), then I do this:

$q2 = "SELECT resort_id, gift_id FROM resort_gift WHERE gift_id = $id";

	$r2 = @mysqli_query($dbc, $q2);

If there is a result of one record (again, there will be either one or no records as this is a one to many relationship:

if (mysqli_num_rows($r2) == 1) {
		$q3 = "SELECT Resort_ID, Resort_Name FROM Resorts";
		$r3 = @mysqli_query($dbc, $q3);
		$row3 = mysqli_fetch_array($r3, MYSQLI_NUM);

I then am creating an array to populate the <option> tag like so:

		while ($row=mysqli_fetch_array($r3)) {
			$options="<OPTION VALUE=\\"$id\\">".$rn.'</option>';

Then in the form I am doing this:

 <?php if (mysqli_num_rows($r3) > 0) {
				?> <select name="Resort_ID">
				<?php } ?> </select><br /><br />

Now here is my question. One of the things that I need to do is, the resort that is tied to the gift certificate that I am editing should be automatically selected, but I still want to see all the resorts since the user could have selected the wrong resort by mistake.
Can someone point out what I am doing wrong?



First thing I see is this

while ($row=mysqli_fetch_array($r3)) {

$options="<OPTION VALUE=\\"$id\\">".$rn.'</option>';

Your while loop uses $row but you are using $row3 inside the while loop…

Second is that you’re overwriting $options every loop through. Need to .= instead of just =
Third is that you have no logic for identifying the matching ID.