/    Sign up×
Community /Pin to ProfileBookmark

creating tr fields according to session values?

hi

here is my code for the question first:

[code=php]
fwrite($handle,'<tr><th>county_UA</th><th>pop_code</th><th>favourite_instrument</th> <th>bbb</th><th>id</th><th>fruit</th><th>prizes</th><th>fguk_code</th><th>fgeu_code</th></tr>’.”n”);
[/code]

this codes writes the rows for the table which looks like this:

[code=html]
<table id=”tab” border=”5″>
<tr><th>county_UA</th><th>pop_code</th><th>favourite_instrument</th> <th>bbb</th><th>id</th><th>fruit</th><th>prizes</th><th>fguk_code</th>
<th>fgeu_code</th></tr>
[/code]

is there way using sessions could do this according to the value of sessions:

so a session value contains county_ua it will write <th>county_UA</th>.

i have done similar but it works fine but not for this:

[code=php] if (isset($_SESSION[‘checkbox2′])) {
fwrite($handle,'<td><xsl:value-of select=”county_UA”/></td>’.”n”);
}

if (isset($_SESSION[‘checkbox3’])) {
fwrite($handle,'<td><xsl:value-of select=”pop_code”/></td>’.”n”);
}

if (isset($_SESSION[‘checkbox4’])) {
fwrite($handle,'<td><xsl:value-of select=”favourite_instrument”/></td>’.”n”);
}[/code]

this basicaly says if the session checkbox4 contains that value print or write this code.

something similar to that would be great.

thanks for the time

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@HuevoosMay 08.2006 — [code=php]fwrite($handle,"<tr><th>$_SESSION[county_UA]</th><th>$_SESSION[pop_code]</th><th>$_SESSION[favourite_instrument]</th> <th>$_SESSION[bbb]</th><th>$_SESSION[id]</th><th>$_SESSION[fruit]</th><th>$_SESSION[prizes]</th><th>$_SESSION[fguk_code]</th><th>$_SESSION[fgeu_code]</th></tr>"."n");[/code]
Copy linkTweet thisAlerts:
@benqauthorMay 08.2006 — hi

many thanks thats working great,

im trying to do something similar this time but with radio buttons

but it would write this value in the xsl:
[code=html]<xsl:sort select="pop_code"/>[/code]

but instead of pop_code it will show what ever the user chose out of 20 radiobuttons or choices but it could only by one obviously out of the 20.

here is the php for that:

[code=php]$_SESSION['radiobutton'] = $_POST['radiobutton'];[/code]


i had a try but nothing again ?

[code=php]if (isset($_SESSION['radiobutton'])) {
fwrite($handle,'<xsl:sort select="pop_code"/>'."n");
}[/code]


and i,m sure i'll need 20 of those lines if it works, please have a look and let me know if its correct, thanks again for your trouble and time

:newbie:
Copy linkTweet thisAlerts:
@HuevoosMay 08.2006 — [code=php]if (isset($_SESSION['radiobutton'])) {
fwrite($handle,'<xsl:sort select="' . $_SESSION['radiobutton']. '"/>'."n");
} [/code]


http://mx2.php.net/manual/en/ref.session.php

?
Copy linkTweet thisAlerts:
@benqauthorMay 08.2006 — hi Huevoos


it works like a charm thanks it works perfectly

can i ask you another question?

is basicaly displaying the fields and choosing a colour from the options given, would you mind if i show ya if so please say so and i'll publish the code

thanks
Copy linkTweet thisAlerts:
@HuevoosMay 09.2006 — don't need to ask, go on
Copy linkTweet thisAlerts:
@benqauthorMay 09.2006 — hi


thanks for getting back to me well here it is,

i,m trying to basicaly give the user an option to colour the fields they selected from the checkboxes:

which are:
[code=html] <fieldset>
<legend>Colours 2</legend>
<input type="radio" name="radiobutton2" value="chocolate" />chocolate
<input type="radio" name="radiobutton2" value="forestgreen" />forestgreen
<input type="radio" name="radiobutton2" value="turquoise" />turquoise
<br />
<input type="checkbox" name="checkbox20" value="county_UA" />county_UA
<input type="checkbox" name="checkbox21" value="pop_code" />pop_code
<input type="checkbox" name="checkbox22" value="favourite_instrument" />favourite_instrument
<input type="checkbox" name="checkbox23" value="bbb" />bbb
<input type="checkbox" name="checkbox24" value="id" />id
<input type="checkbox" name="checkbox25" value="fruit" />fruit
<input type="checkbox" name="checkbox26" value="prizes" />prizes
<input type="checkbox" name="checkbox27" value="fguk_code" />fguk_code
<input type="checkbox" name="checkbox28" value="fgeu_code" />fgeu_cod
</fieldset>[/code]


here is the code i came up with so far but it doesnt work:

[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['checkbox1']))
fwrite($handle,'<td bgcolor="$colour"<xsl:value-of select="county_UA"/></td>'."n");[/code]


basicaly the output should look like somthing like this, if the bbb and favourite_instrument are checked to be coloured:

[code=html]
<td><xsl:value-of select="pop_code" /></td>

<td bgcolor="brown"><xsl:value-of select=" favourite_instrument" /></td>

<td bgcolor="green"><xsl:value-of select="bbb" /></td>

<td><xsl:value-of select=" id" /></td>

<td><xsl:value-of select="fruit" /></td>[/code]


what do you think?

thanks
Copy linkTweet thisAlerts:
@HuevoosMay 09.2006 — It is because the single quotes,
[code=php]fwrite($handle,'<td bgcolor="$colour"<xsl:value-of select="county_UA"/></td>'."n");[/code]
if you want to use a variable inside a string you should double quote the string and escape other double quotes inside it
[code=php]fwrite($handle,"<td bgcolor="$colour"<xsl:value-of select="county_UA"/></td>"."n");[/code]
Copy linkTweet thisAlerts:
@benqauthorMay 09.2006 — hi

i'll give it a try thanks
Copy linkTweet thisAlerts:
@benqauthorMay 09.2006 — hi

thats great but what if i just wanted to fwrite colour

so instead of writing the whole line:
[code=html]<td bgcolor="#D2691E"><xsl:value-of select="county_UA"/></td>[/code]


i just wanna write this:
[code=html]bgcolor="#D2691E"[/code]

so it would look like this i think:

[code=php]
<td bgcolor= fwrite($handle,"$colour"><xsl:value-of select="county_UA"/></td>"."n");[/code]


can you do some thing like this?

thanks
Copy linkTweet thisAlerts:
@benqauthorMay 09.2006 — hi

it works but it does this, it doubls the value and it colours them

here is a picture to see what i mean!

http://img166.imageshack.us/my.php?image=untitled28eq.gif

thanks
×

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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...