Click to See Complete Forum and Search --> : creating tr fields according to session values?
hi
here is my code for the question first:
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");
this codes writes the rows for the table which looks like this:
<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>
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:
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");
}
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
Huevoos
05-08-2006, 12:14 PM
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");
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:
<xsl:sort select="pop_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:
$_SESSION['radiobutton'] = $_POST['radiobutton'];
i had a try but nothing again :(
if (isset($_SESSION['radiobutton'])) {
fwrite($handle,'<xsl:sort select="pop_code"/>'."\n");
}
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:
Huevoos
05-08-2006, 12:27 PM
if (isset($_SESSION['radiobutton'])) {
fwrite($handle,'<xsl:sort select="' . $_SESSION['radiobutton']. '"/>'."\n");
}
http://mx2.php.net/manual/en/ref.session.php
;)
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
Huevoos
05-09-2006, 10:16 AM
don't need to ask, go on
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:
<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>
here is the code i came up with so far but it doesnt work:
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");
basicaly the output should look like somthing like this, if the bbb and favourite_instrument are checked to be coloured:
<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>
what do you think?
thanks
Huevoos
05-09-2006, 12:31 PM
It is because the single quotes,
fwrite($handle,'<td bgcolor="$colour"<xsl:value-of select="county_UA"/></td>'."\n");
if you want to use a variable inside a string you should double quote the string and escape other double quotes inside it
fwrite($handle,"<td bgcolor=\"$colour\"<xsl:value-of select=\"county_UA\"/></td>"."\n");
hi
i'll give it a try thanks
hi
thats great but what if i just wanted to fwrite colour
so instead of writing the whole line:
<td bgcolor="#D2691E"><xsl:value-of select="county_UA"/></td>
i just wanna write this:
bgcolor="#D2691E"
so it would look like this i think:
<td bgcolor= fwrite($handle,\"$colour\"><xsl:value-of select=\"county_UA\"/></td>"."\n");
can you do some thing like this?
thanks
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