Reply to Re: [PHP] Modifying data in forms with values

Your name:

Reply:


Posted by Al on 09/13/05 21:31

Murray @ PlanetThoughtful wrote:
>>I have to create registration forms all the time for people in the office
>>and
>>what I keep running into is that I need a way for when they edit a field
>>that
>>the drop-down list of choices is automatically set for the right now.
>>
>>I have 100+ counties in one list, but I don't want to write 100+ if
>>statements
>>for checking to see if the value of $county equals the value of the field
>>I am
>>drop down choice.
>>
>>Anyone have some quick solutions?
>>
>>I have radio buttons as well, but going to use a drop-down list for the
>>editing
>>pages to make it all simple.
>
>
> Hi Robert,
>
> As a suggestion, why not put your counties in an array (are you taking them
> from a recordset? If so, same idea applies) and use foreach() to iterate
> through the array, building the select list. When $county equals the current
> value of the array, include " SELECTED" in the select HTML you are building.
> One if statement should handle the situation nicely.
>
> Much warmth,
>
> Murray @ PlanetThoughtful
> ---
> "Lost in thought..."
> http://www.planetthoughtful.org

Here is an example of what Murray suggested. $sort_options is an array [list]of counties in your case.

$report .=
"<div style=\"font-weight:bold; margin-top:2em\">Sort the index by:
<select name=\"sort_by\">\n";

$sort_by= foo;

foreach($sort_options as $option=> $label){

$sel=($option== $sort_by)? 'SELECTED' : '';
$report .= "<option value=\"$option\" $sel>$label</option>\n";
}//end foreach
$report .= "</select>\n";

[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

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