LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-10-2006, 10:43 AM   #1
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Rep: Reputation: 15
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:

PHP Code:
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");

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


Code:
<td><xsl:value-of select="fgeu_code"/></td>
not:

Code:
<td bgcolor="#D2691E"><xsl:value-of select="fgeu_code" /></td>
can anyone see why?

thanks for your time
 
Old 05-10-2006, 08:18 PM   #2
thedude2010
LQ Newbie
 
Registered: Oct 2002
Posts: 12

Rep: Reputation: 0
You may need to enable php for that folder, if don't have access to the apache config files you can use .htaccess

AddType application/x-httpd-php .html .php


or just change ext to php
 
Old 05-11-2006, 04:15 AM   #3
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
If checkbox10 is set, it'll never show a colour, regardless of the value of radiobutton1 or dropdown. I presume that's intentional. But it's clear from the results you've described that checkbox10 is always set.

Have you tried confirming the value of checkbox10? Remember that if it's set to zero or blank, it will still be set, so will still trigger the condition in your code; maybe you need to change the if() to check whether it's got a value greater than zero, rather than just checking if it's set?

It's hard to say any more than that, because I'd need to see the code where you're actually setting these variables. Without knowing what values you've got, it's not going to be easy to know why they're triggering the wrong bits of code here.
 
Old 05-11-2006, 04:21 AM   #4
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Original Poster
Rep: Reputation: 15
hi

thanks for getting back to me, basialy if the checkbox10 is set than it will display that dat, if the the checkbox10 is set and than chose it to be coloured than colour it witth chosen colour.

if you quickly look at this thread and the includedlink to the pocture of the expected result you will see what am trying to achieve.

have and llook if you can

thanks for your time
 
Old 05-11-2006, 08:51 AM   #5
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
I can't see any links or pictures? Not sure what you meant there.

But anyway...
Lets say your form contains this:
<input type='checkbox' name='checkbox10' value='1' />

...and your PHP program does something like this:
$_SESSION['checkbox10'] = $_REQUEST['checkbox10'];

...and then on to the code you quoted in your question...

In that case, it's likely that $_SESSION['checkbox10'] will always be set, even if you it doesn't actually have a value, so therefore your if(isset($_SESSION['checkbox10'])) statement will always get the same result.

A better way of doing it would be to write:
if($_SESSION['checkbox10']=='1')

ie -- instead of using isset(), look for the actual value in the checkbox.

Hope that helps.

All the best.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multithreaded RPC Servers for Linux.Thread-safe code writing dba477 Red Hat 1 08-25-2010 01:33 AM
Incorrect PHP code is working, shoud I "fix" it? rblampain Programming 6 04-28-2006 11:33 PM
merge ASP code with PHP code.. possible ?? ALInux Programming 7 12-30-2005 09:40 AM
Book about writing secure code Covel Linux - Security 1 06-12-2004 02:53 AM
writing c code for getting stats from a network card h/w Programming 2 10-01-2003 01:51 PM


All times are GMT -5. The time now is 01:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration