Showing the selected value in Drop down select using PHP
<p>I am trying to load a drop down option values based on database information. I have the following code and its working fine but I don't know how to code in the following to show the selected value</p>

<pre><code>$output = null;

foreach ($records-&gt;result() as $row){

  $output .= "&lt;option value='".$row-&gt;sub_category_id."'&gt;".$row-&gt;sub_category_name."&lt;/option&gt;";

}
return $output;
</code></pre>

<p>I know I should be using something like following, but I can't understand how to put the following code together with the above codes.</p>

<pre><code> if($row-&gt;sub_category_id==$sub_category_id){select="selected"}
</code></pre>

<p>Could you please show me?
thanks :)</p>
