RE: [PHP] if inside an echo.
- From: edward@xxxxxxxxxx ("Edward Kay")
- Date: Tue, 31 Jul 2007 12:36:24 +0100
-----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
.
- Follow-Ups:
- Re: [PHP] if inside an echo.
- From: "M. Sokolewicz"
- Re: [PHP] if inside an echo.
- References:
- if inside an echo.
- From: "Hulf"
- if inside an echo.
- Prev by Date: Re: [PHP] Includes eating up my time
- Next by Date: Re: Includes eating up my time
- Previous by thread: if inside an echo.
- Next by thread: Re: [PHP] if inside an echo.
- Index(es):
Relevant Pages
|