[UPHPU] Pastebin.org, Would Anybody like to help me create a pastebin?

Wade Preston Shearer lists at wadeshearer.com
Sun Aug 5 20:53:27 MDT 2007


> // 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>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20070805/14b91460/smime.bin


More information about the UPHPU mailing list