Mantaining dropdown.. Script is so long?
<p>I've read that using session is one way to retain the values from PHP submit failure. The data is wiped out as soon as you send the form to the server so to get back the data, a session should be use. I have a dropdown that is a list of country. It contains more than 60-80 countries. I used the ternary condition to make the script shorter but it's still very long and tiresome.</p>

<p>It looks like this</p>

<pre><code>&lt;option value="Afghanistan" &lt;?php echo (isset($_SESSION["errors"]) &amp;&amp; $_SESSION["country"] == "Afghanistan") ? "SELECTED" : ""; ?&gt; &gt;Afghanistan&lt;/option&gt;
&lt;option value="Albania" &lt;?php echo (isset($_SESSION["errors"]) &amp;&amp; $_SESSION["country"] == "Albania") ? "SELECTED" : ""; ?&gt;&gt;Albania&lt;/option&gt;
&lt;option value="Algeria" &lt;?php echo (isset($_SESSION["errors"]) &amp;&amp; $_SESSION["country"] == "Algeria") ? "SELECTED" : ""; ?&gt;&gt;Algeria&lt;/option&gt;
</code></pre>

<p>As I continue this, I thought that there must be another way. Is this a good method? When I see php scripts that is very long, I tend to think that I'm not doing the right way. The list goes on up till now.</p>
