RE: if inside an echo.

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

 




> -----Original Message-----
> From: Hulf [mailto:ross@xxxxxxxxxxxxxx]
> Sent: 31 July 2007 12:11
> To: php-general@xxxxxxxxxxxxx
> Subject:  if inside an echo.
> 
> 
> I am outputting a selectbox and want to do the follwoing. How can 
> I add the 
> IF statement inside the the echo?
> 
> 
> for ($value = 0; $value <= 2000; $value += 100) {
> 
>  echo "<option value=\"$value\" if ($min_rent==$value) {echo 
> selected="selected" }> $value</option>";
> 
>   }
> 

Just split it into multiple echo statments:

for ($value = 0; $value <= 2000; $value += 100) {

   echo "<option value=\"$value\"";
   if ($min_rent==$value)
      echo " selected=\"selected\"";
   echo "> $value</option>";

}

Edward

-- 
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