/    Sign up×
Community /Pin to ProfileBookmark

php code not writing or working?

hi

i,m basicaly trying to colour the columns when the user picks from the dropdownlist and radio buttons here is the code:

[code=php]
if (isset($_SESSION[‘radiobutton1’]))
{
if ($_SESSION[‘radiobutton1’] == ‘chocolate’){
$colour = “#D2691E”;
}elseif ($_SESSION[‘radiobutton1’] == ‘forestgreen’){
$colour = “#228B22”;
}elseif ($_SESSION[‘radiobutton1’] == ‘turquoise’){
$colour = “#00DED1″;
}
}

if (isset($_SESSION[‘checkbox10′])) {
fwrite($handle,'<td><xsl:value-of select=”fgeu_code”/></td>’.”n”);
}else{
if($_SESSION[‘dropdown’] == “fgeu_code”) {
fwrite($handle,'<td bgcolor=”$colour”><xsl:value-of select=”fgeu_code”/></td>’.”n”);
} [/code]

but is not working or wrtiting the lines when it does it only writes:

[CODE]<td><xsl:value-of select=”fgeu_code”/></td>[/CODE]

not:

[CODE]<td bgcolor=”#D2691E”><xsl:value-of select=”fgeu_code” /></td>[/CODE]

can anyone see why?

thanks for your time

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@lostnightsMay 10.2006 — Could try these.
[CODE]
td {
background: #<?php echo $color; ?>;
}
[/CODE]

[CODE]
<form action="page.php">
<select name="color">
<option value="D2691E">Color 1</option>
<option value="228B22">Color 2</option>
</select>
</form>
[/CODE]
Copy linkTweet thisAlerts:
@NogDogMay 10.2006 — Your final fwrite() is in an else block which will only be executed if $_SESSION['checkbox10'] is not set. Since the "<td><xsl:value-of select="fgeu_code"/></td>" is getting output, we can assume that that session value [i]is[/i] set, so the else will not execute. Not knowing exactly what the desired logic is, I can only speculate that perhaps you should remove the "else"?
Copy linkTweet thisAlerts:
@NogDogMay 10.2006 — PS: Proper indenting of your code would probably make this more obvious:
[code=php]
if (isset($_SESSION['radiobutton1']))
{
if ($_SESSION['radiobutton1'] == 'chocolate'){
$colour = "#D2691E";
}elseif ($_SESSION['radiobutton1'] == 'forestgreen'){
$colour = "#228B22";
}elseif ($_SESSION['radiobutton1'] == 'turquoise'){
$colour = "#00DED1";
}
}

if (isset($_SESSION['checkbox10'])) {
fwrite($handle,'<td><xsl:value-of select="fgeu_code"/></td>'."n");
}else{
if($_SESSION['dropdown'] == "fgeu_code") {
fwrite($handle,'<td bgcolor="$colour"><xsl:value-of select="fgeu_code"/></td>'."n");
}
} // should be a final closing brace here
[/code]
×

Success!

Help @benq spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...