Adding selected to option drop down list based on user's previous selection
<p>In the vendor drop down menu I need to dynamically add "selected" based on what the user input at the previous screen. I have what I think the loop will basically look like but I can't get it to work. Any help would be much appreciated, I have looked at other examples but they are not like this one. Here is my code:</p>

<pre><code> &lt;?php  
 $set_date =$_POST['set_date'];
 include "../include/setup.inc.php";
 $query="select * from quote_distro where set_date ='2011-10-05'";
 $result = mysql_query($query);
  if (!$result) {echo "&lt;p&gt;&lt;b&gt;".$query ."&lt;/b&gt;&lt;/p&gt;";echo 'MySQL Error: ' . mysql_error(); return;}
echo '&lt;br /&gt;&lt;br /&gt;';
echo '&lt;form name="edit_quote_setting_'.$row['qdid'].'" action="'.$self.'" method="post"&gt;&lt;table align="center" border="1" width="800px"&gt;
               &lt;tr&gt;&lt;td width="10%"&gt;Email:&lt;/td&gt;&lt;td width="20%"&gt;&lt;input type="text" MAXLENGTH=40 size="30" name="email" value="'.$row['agent_email'].'"&gt;&lt;/td&gt;
                &lt;td width="10%"&gt;#Quote:&lt;/td&gt;&lt;td width="10%"&gt;&lt;input type="text" MAXLENGTH=4 size="3" name="num_quote" value="'.$row['num_quote'].'"&gt;&lt;/td&gt;
                &lt;/td&gt;&lt;td width="10%"&gt;Vendor&lt;/td&gt;&lt;td width="40%"&gt;&lt;select id="vendor1" name="vendor[1]"&gt;      
                        &lt;option value="Regent Seven Seas Cruises"'.test().'&gt;Regent&lt;/option&gt;
                        &lt;option value="Silversea Cruises"&gt;Silversea&lt;/option&gt; 
                        &lt;option value="Oceania Cruises"&gt;Oceania&lt;/option&gt; 
                        &lt;option value="Windstar Cruises"&gt;Windstar&lt;/option&gt;
                        &lt;option value="Paul Gauguin Cruises"&gt;Paul Gaugin&lt;/option&gt;
                        &lt;option value="all"&gt; - No Preference - &lt;/option&gt;
                        &lt;/select&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input name="qdid" type="hidden" value="'.$row['qdid'].'" /&gt;
                &lt;input name="submit" id="submit" type="submit"  class="go" value="Update Quote Setting" /&gt;
                &lt;/tr&gt;&lt;/form&gt;&lt;table&gt;';           
        }
        function test(){
        $vensel = $row['vendor'];
        if($vensel = "Regent Seven Seas Cruises" ){ echo "selected" }
        }//etc for each option
                ?&gt;
</code></pre>
