Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
highlighting with db options with if statements
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/11/09 20:52 
I need to know if I am doing this correctly (well i know i am not because i wouldnt have to ask this if I was) I am trying to add a bg color to a cell depending on the db entry here is the code


Code
         if ($task_status == 'New') {
         echo 'td bgcolor="#FC0000" ';
         }



I also tried


Code
              if ($task_status == 'New') {
              $bgcolor = "#FC0000";
         }

I am thinking htis goes some where in the Select and Order by area......

Code

        // Get all of the Tasks in Order of Update
        $req = "SELECT *
                  FROM {$jamroom_db['wkTracker']}
                  ORDER BY task_id ASC";
        $_rt = dbQuery($req,'NUMERIC');
        if (isset($_rt) && is_array($_rt)) {
           foreach ($_rt as $_task) {
               $dat[1]['title'] = $_task['task_id'];


I am thinking that its some where in the beginning part of this which is why i didnt copy the whole area is this the correct place some what or should i put it some where else.


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 02:09 
I'm not too sure what you are asking, but you can change the style of your table cell by adding inline css to your table output:

dat[1]['title'] = $_task['task_id'];
dat[1]['style'] = "padding: 20px";


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/12/09 05:33 

SteveX:
I'm not too sure what you are asking, but you can change the style of your table cell by adding inline css to your table output:

dat[1]['title'] = $_task['task_id'];
dat[1]['style'] = "padding: 20px";

What I am trying to do is depending on the option chosen then the cell would be a different color


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 05:52 
Try this:

Code
dat[1]['title'] = $_task['task_id'];
if $_task['task_status'] == 'New' {
    dat[1]['style'] = "background-color: #FC0000;";
{/if}



_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/12/09 08:27 
The coloring alone works, can not get it to work with the task status though

Code
Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home4/sliceofa/public_html/4sldemo/wkTracker.php on line 334

I have tried a few different changes and nothings worked so far
still trying to work it out though

Code
                   if $_task['task_status'] == 'New' {
               $dat[6]['style'] = "background-color: #FC0000;";
                   {/if
}


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 08:30 
Sorry, that was my mistake.

That {/if} should just be }


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/12/09 10:19 
I tried the following

Code
                   if $_task['task_status'] == 'New' {
               $dat[6]['style'] = "background-color: #FC0000;";
                   /if }

and came up with


Code
Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /home4


So I tried

Code

           if ($_task['task_status']) == 'New' {
               $dat[6]['style'] = "background-color: #FC0000;";
                   /if }


and came up with


Code
Parse error: syntax error, unexpected T_IS_EQUAL in /home4


I tried a few other variations with brackets so I do not know where to go from here


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 10:20 

Code
if ($_task['task_status'] == 'New') {
               $dat[6]['style'] = "background-color: #FC0000;";
 }



_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/12/09 13:14 
Ahhhh sorry I isunderstood the removing the /if partthanks now I am almost there
so now everthing shows up as red no matter what the status is but now I am able to see the page

Code
                 if ($_task['task_status'] == 'New') {
               $dat[6]['style'] = "background-color: #008000;";
 }

I thought that maybe if I added an else statement then it would make the other option the other color
but that just came up with another error
so at this point the entire colmn under $dat6 is green not just the new items


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 16:35 
If the entire column is green, then either $_task['task_status'] == 'New' for every row, or you are applying this to the header of the column rather than the row.


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 16:39 
Does the code following the dat section you posted above say htmlPageSelect('header',$dat); or htmlPageSelect('row',$dat); or htmlChooser('header',$dat); or similar?

Is it a header or a row you are applying this to?


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/12/09 16:44 
If you add in a fdebug before your 'if' what gets printed out to your debug log?


Code
fdebug($_task);
if ($_task['task_status'] == 'New') {
               $dat[6]['style'] = "background-color: #008000;";
 }



_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/12/09 18:40 

SteveX:
If the entire column is green, then either $_task['task_status'] == 'New' for every row, or you are applying this to the header of the column rather than the row.


I believe am applyig this to the row isn't that what the $dat[6] does

Code

        htmlPageSelect('header',$dat);
        unset($dat);

        // Get all of the Tasks in Order of Update
        $req = "SELECT *
                  FROM {$jamroom_db['wkTracker']}
                  WHERE task_status = 'New'
                  ORDER BY task_update DESC";
        $_rt = dbQuery($req,'NUMERIC');
        if (isset($_rt) && is_array($_rt)) {
           foreach ($_rt as $_task) {
               $dat[1]['title'] = $_task['task_id'];
               $dat[2]['title'] = $_task['task_update'];
               $dat[3]['title'] = $_task['task_start'];
               $dat[4]['title'] = "<a href='{$jamroom['jm_htm']}/wkTracker.php?mode=update&task_id={$_task['task_id']}'>{$_task['task_subject']}</a>";
               $dat[5]['title'] = $_task['task_category'];
               $dat[6]['title'] = $_task['task_status'];
               $dat[6]['style'] = "background-color: #FC0000;";
                                 
               htmlPageSelect('row',$dat);
           }
        }
        htmlPageSelect('footer');
        jmBodyEnd();
        jmHtmlEnd();
        exit;
        break;



_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 10/12/09 18:58 

SteveX:
If you add in a fdebug before your 'if' what gets printed out to your debug log?


Code
fdebug($_task);
if ($_task['task_status'] == 'New') {
               $dat[6]['style'] = "background-color: #008000;";
 }


All iot shows is al of the tests that I have

[code]
(19:19:53 0.75155500)-(wkTracker.php)-(8679856)-(27378)-(68.33.250.212)
Array
(
[task_id] => 1
[task_band_id] => 2
[task_category] => Classified
[task_subject] => Highlight Ads
[task_description] => Need to find a way to add a highlight to the ads which are being displayed
[task_notes] =>
[task_status] => New
[task_level] => Level 1
)[code]


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 10/13/09 02:27 
htmlPageSelect('row',$dat); <<< this means you are using a row, but you can also use your $dat array in a header, or I guess a footer.

This definitely works, I have just tried it here:


Code
                   if ($_answer['id'] == 2) {
                       $dat[2]['style'] = 'background-color:#FF0000';
                   } else {
                       $dat[2]['style'] = 'background-color:#CCCC00';
                   }


Try it with an id or something that you are sure is different for each result.


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

12Next >
 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.