> This is not a big thing.
> But I am looking at this thinking there is a way to make the code take up
> even less lines.

> for($i=01;$i<=50;$i++)  {
>          if (!empty($content))   {
>                  if ($row[$content]==$states[$i])
>                          echo "<option value=\"$states[$i]\"
> selected>$nstates[$i]\n";
>                  else
>                          echo "<option
value=\"$states[$i]\">$nstates[$i]\n";
>          }
>          else    {
>                  if ($dstate == $states[$i])
>                          echo "<option value=\"$states[$i]\"
> selected>$nstates[$i]\n";
>                  else
>                          echo "<option
value=\"$states[$i]\">$nstates[$i]\n";
>          }
> }

i would try:

for($i=01;$i<=50;$i++) {
    if(!empty($content) && $row[$content] == $states[$i])
        $selected = " selected";
    elseif($dstate == $states[$i])
        $selected = " selected";
    else
        $selected = "";
    echo "<option
value=\"".$states[$i]."\"".$selected.">".$nstates[$i]."</option>";
}

trading four echo's for a one echo and a extra var and nest the ifs

> Basically I want to check for two possible conditions to make an item
selected.
> If the first one is valid then do not check for the other.
>
> Get what I mean?
> Any expert programmers out there with the way to chop this even further?

test it :)

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--------------
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|                                                       -- Douglas Adams


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

Reply via email to