In your valued opinions, which is a better programming standard to follow<br><br>I have a maintenance page with SELECT boxes that offer content for a field.<br><br>Let&#39;s take states for instance<br><br>With ordinary html or even php printing html, the code would look like
<br><br>&lt;select&gt;<br>&nbsp; &lt;option value=state_abrv&gt;state_abrv&lt;/option&gt;<br>&nbsp; {repeat for each state}<br>&lt;/select&gt;<br><br>Pros: No preprocessing at all Cons: HTML is for little girls<br><br>print(&quot;&lt;select&gt;\n&quot;.
<br>&quot;&lt;option value=\&quot;state_abrv\&quot;&gt;state_abrv&lt;/option&gt;&quot;.<br>{repeat for each state}<br>&quot;&lt;/select&gt;&quot;);<br><br>Pros: Call to print only once, No need to htmlize the content Cons: Still html
<br><br>A more dynamic approach might be<br>&lt;?<br><br>$sql=&quot;SELECT st_abrv FROM schema.table-with-st_abrv ORDER BY st_abrv;&quot;;<br><br>$result = pg_query($sql) or die(&quot;You know that the table doesn&#39;t exist); // $dbconn already established by pg_pconnect()
<br><br>print(&quot;&lt;select&gt;&quot;);<br><br>while ($rows = (pg_fetch_array($result,NULL,PGSQL_ASSOC)) {<br>&nbsp;<br>&nbsp; print(&quot;&lt;option value=\&quot;$rows[st_abrv]\&quot;&gt;$rows[st_abrv]&lt;/option&gt;&quot;);<br>
<br>}<br><br>print(&quot;&lt;/select&gt;&quot;);<br><br>pg_free_result($result);<br><br>?&gt;<br>Pros: Dynamically generated content, less typing, scalable Cons: More calls to print, More preprocessing <br><br>The first approach seemed okay for things that don&#39;t change, although it makes for a lot of typing, which I try to avoid at all costs.
<br>However, it doesn&#39;t provide a GUI avenue for adding more options. For states, this probably won&#39;t be a problem, but other items may change. Making them available to the maintenance page would require editing the actual code.
<br><br>The second approach offers more dynamics and less typing, but requires more server preprocessing, before the users gets the page their looking for.<br><br>So I ask, which would you prefer?<br>&nbsp;<br clear="all">?&gt;
<br>-- <br>In vino veritas.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[In wine there is truth.]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Pliny