Re: <OPTION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, October 26, 2006 8:31 am, Jochem Maas wrote:
> bunch of space wasters ;-)
>
> <?php foreach (range(1, 31) as $d) echo '<option value="',$d,'"',($d =
> $selDay?'
> selected="selected"':''),'>',$d,'</option>'; ?>

You messed up. :-)

$d == $selDay would be the correct expression in the middle of that.

My personal choice is:

$last_day = 31; //calculated from date()/mktime() etc
for ($day = 1; $day <= $last_day; $day++){
  $selected = $chosen_day == $ ? 'selected="selected"' : '';
  echo "  <option $selected>$day</option>\n";
}

I don't *think* the w3c requires/recommends a value= in there, if the
label *IS* the value, but can live with it either way...
  echo "  <option value=\"$day\" $selected>$day</option>\n";
is fine.

I used to be distracted by \" but I've grown so used to it that it no
longer bothers me in my reading flow, unless it's excessive and the
expression spans multiple lines.

Separation of logic and presentation is all very well, but this isn't
even business logic.  It's "presentation logic" which, to me,
shouldn't be crammed into the complex business portion of my
application.

I'd much rather have the complex business logic focus on the
application needs than the minutae of date formatting.

It's all down to personal choice, though.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux