Database Forum
Web Database Register Members List Calendar FAQ

 
Go Back   Database Forum > Database Management > PHP & MySQL
User Name
Password

Reply
 
Thread Tools Search this Thread Display Modes
Default Highlighting a cell based on content
08-02-2007, 08:02 AM #1  

lost2ny
Junior Member

 
Status: Offline
Posts: 12
Join Date: Aug 2007

Can anyone out there think of a way that I can highlight a cell in the table view base on its content? I have a client who wants to easily see which records have certain values in a particular field. Sorting won't help, as the key values are pretty much random such that 03.1, 03.2 and 03.5 are all important values, but 03.3 and 03.4 are not.

My thought was to create a kind of "telltale" where I would have a table of the key values and have the field change color when it's value matches one in the table. It's a method I used to use a lot when I was programming in Access VB.

I've been fumbling around for a couple of days now trying to figure out how I might do that in PHP or javascript, but haven't come up with any ideas. I was hoping someone out there may have done this sort of thing before and could point me in the right direction or even suggest a better method of giving my client what he needs.

I'm using PHPMagic Pro 3 on an Apache 2 server with PHP 5.2 and MySQL 5. PHPMagic has been a huge help thus far, allowing me to create a very nice application very quickly, but now of course I have a lot of code that I'm not very familiar with. It makes customizing a bit harder.
Reply With Quote

Default
08-05-2007, 03:43 PM #2  

twenty1
Senior Member

 
Status: Offline
Posts: 221
Join Date: Mar 2005
Location: Iowa, USA

I'm sure it can be done using a php query script that has logic built into the query. Maybe poke around in some php forums.
Reply With Quote

Default
08-06-2007, 02:52 PM #3  

lost2ny
Junior Member

 
Status: Offline
Posts: 12
Join Date: Aug 2007

I realize now that I didn't finish my question properly. Twenty1 is quite right and I've found a couple of different possibilities, but I'm not sure how to integrate it into the code that PHPMagic creates. Where would I put something like that? I've been able to change the look of all of the cells in a given column by modifying the code in "mycode_templateTV.html", but I'm not sure if there's any way of adding any sort of branching statement there such as an "IF/ELSE". Is there a way, or is there somewhere else that would be better?

Best regards,
Carl
Reply With Quote

Default
08-07-2007, 07:16 PM #4  

twenty1
Senior Member

 
Status: Offline
Posts: 221
Join Date: Mar 2005
Location: Iowa, USA

It would probably go in your generated tablename_dml.php file within the ->
function insert() section. What would the evaluation look like?

IF fieldname1 > 0 then ......

However the page display is controlled by styles that could be another option.
Reply With Quote

Default
08-09-2007, 08:08 PM #5  

twenty1
Senior Member

 
Status: Offline
Posts: 221
Join Date: Mar 2005
Location: Iowa, USA

Did your get things worked out..

I think styles may be the way to go. For example if the field value is 1 default is blue. If value is 2 then background is red.

td.special { background-color:<? echo (value==1)?'blue':'red'; ?>; }

This would work in PHP for this cell after creating the style -

<td class="special">

Good luck
Reply With Quote

Default
08-14-2007, 02:14 PM #6  

lost2ny
Junior Member

 
Status: Offline
Posts: 12
Join Date: Aug 2007

The styles route is the way I'm trying to go, but I have a problem that I don't really understand. I would have thought that changing the style should happen in tablename_templateTV.html, but some of the attributes seem to be controled by datalist.php so it doesn't look right. I haven't been able to take the time to go through the code and figure it out, so I'm stuck.

Thank you,
Carl
Reply With Quote

Default
08-15-2007, 10:44 AM #7  

Kayla
Senior Member

 
Status: Offline
Posts: 302
Join Date: Mar 2005
Location: USA

Did you edit the generated styes file to add your own style or edit the styles from within phpmagic.
Reply With Quote

Default
08-16-2007, 01:19 PM #8  

lost2ny
Junior Member

 
Status: Offline
Posts: 12
Join Date: Aug 2007

I added it myself - as I understand it, phpmagic only allows you to edit the existing styles, but I would need a new style to apply to a single column or better yet individual cells.
Reply With Quote

Default
08-17-2007, 03:34 PM #9  

Kayla
Senior Member

 
Status: Offline
Posts: 302
Join Date: Mar 2005
Location: USA

Open the generated style.css and add your style. It's that simple....
Reply With Quote

Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 10:54 PM.

Powered by: vBulletin Version 3.7.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Database Forums

Help support our forum assistants and product development ->

go to top go to top