Reply to Re: php best practise

Your name:

Reply:


Posted by Richard Levasseur on 03/10/06 21:04

Best practice would be to use a class that encapsulates all of this,
where the basic logic would be, more or less, in a simple model:
Have a value that keeps the track of the selected item, an array of all
the items, and a loop that checks if the currently outputted value is
selected or not.

in almost-correct-code:

$options = array();
$options['msword'] = 'MS Word';
$options['txt'] = 'Text File';
$selectedKey = null;

echo "<selct bla bla>";
foreach($options as $key=>$value) {
$selected = '';
if($key == $selectedKey)
$selected = 'selected';
}
echo "<option name='foo' value='$key' $selected>$value</option>"
}
echo "</select>"

You can use the same procedure for radio buttons.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация