// Grabbed from Google; the year choices aren't even dynamic.
<select name="day"><?php
  for ($i = 1; $i <= 31; $i++) {
   echo "<option value=\"$i\">$i</option>\n";
  }
 ?></select>
 <select name="month"><?php
  for ($i = 1; $i <= 12; $i++) {
   $monthname = date(‘F‘, mktime(12, 0, 0, $i, 1,
     2005));
   echo "<option value=\"$i\">$monthname</option>";
  }
 ?></select>
 <select name="year"><?php
  for ($i = 2005; $i <= 2010; $i++) {
   echo "<option value=\"$i\">$i</option>";
  }
 ?></select>

I consider your example breaking the separation of business and display logic. The front-end should only have display logic; it shouldn't be performing calculations. You have business logic in your example. The backend should take care of that and only pass variables and arrays to the front-end.

The front-end could (should) look like this:

<select name="day">
        <? foreach ($days as $day) { ?>
        <option value="<? $day ?>"><? $day ?></option>
        <? } ?>
</select>

<select name="month">
        <? foreach ($months as $month) { ?>
        <option value="<? $month ?>"><? $month ?></option>
        <? } ?>
</select>

<select name="year">
        <? foreach ($years as $year) { ?>
        <option value="<? $year ?>"><? $year ?></option>
        <? } ?>
</select>

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to