RE: [PHP] if inside an echo.





-----Original Message-----
From: Hulf [mailto:ross@xxxxxxxxxxxxxx]
Sent: 31 July 2007 12:11
To: php-general@xxxxxxxxxxxxx
Subject: [PHP] 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
.



Relevant Pages

  • Re: Possibile bug?
    ... I think it's not normal what's outputting to me... ... function foo() ... echo ''; ... Lavorate voi - schiavi dei soldi - che non sentite la puzza della ...
    (comp.lang.php)
  • Re: nested loops only loop once
    ... loops for two arrays was not outputting the desired results, ... combined both arrays into one while loop. ... echo "more html"; ...
    (comp.lang.php)
  • Re: [PHP] if inside an echo.
    ... if inside an echo. ... I am outputting a selectbox and want to do the follwoing. ...
    (php.general)
  • Re: Difference between cat and echo
    ... > "This is a test message" ... > However for the echo command I get "echo " in the subject but the body is empty. ... > This made me wonder and hence ask you guys, why does cat work in ... > outputting the message while echo doesn't? ...
    (Fedora)
  • Re: Need some help on header refresh...
    ... the echo -1... ... By discarding the buffer you're not outputting anything, at least not anything that's outputted after the buffer started. ... If you output something useless there you should prevent that output in the first place, if you are outputting something usefull there, it won't be sent, and is discarded. ...
    (comp.lang.php)