kirchaj
Posts: 215
|
| Posted: 02/13/2008, 9:04 AM |
|
Ok guys, I am at my limit. What I am trying to do is display an image if a date exists, if it doesn't exist, display a different one. I am working with a postgres database and a date field. Here is my code in the beforeshowrow event
$goodimage='images/greyscale_10.gif';
$warningimage='images/greyscale_12.gif';
if ($admit_student->crimechk->GetValue() >= '01/01/1980') {
$admit_student->crimechk_image->SetValue($goodimage);
} else {
$admit_student->crimechk_image->SetValue($warningimage);
}
I get a image to display but do not get it to change when the date changes.
Any ideas?
Thanks for the help
TK
|
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 02/13/2008, 7:35 PM |
|
kirchaj
Is crimechk a datefield or a txt/string field?? You may be compare a date array and a string??
|
 |
 |
kirchaj
Posts: 215
|
| Posted: 02/14/2008, 6:09 AM |
|
MamboBrown,
The field(s) in question are all date fields. What I really need to know is if the date exists. If it exists then one image needs to be displayed. If the date does not exist, then I need to display a different image.
What I am doing is creating a status page for our students to know if they have completed all of their tasks. Green is good, red is bad sort of thing. But most of our fields are dates indicating they turned the appropriate "stuff" in.
Any help would be greatly appreciated.
TK
|
 |
 |
datadoit
|
| Posted: 02/14/2008, 6:35 AM |
|
kirchaj wrote:
> MamboBrown,
>
> The field(s) in question are all date fields. What I really need to know is if
> the date exists. If it exists then one image needs to be displayed. If the date
> does not exist, then I need to display a different image.
>
> What I am doing is creating a status page for our students to know if they have
> completed all of their tasks. Green is good, red is bad sort of thing. But
> most of our fields are dates indicating they turned the appropriate "stuff" in.
>
> Any help would be greatly appreciated.
>
> TK
> ---------------------------------------
In that case you can just check the field for a value:
if ($Container->crimechk->GetValue()) {
$Container->crimechk_image->SetValue($goodimage);
}
else {
$Container->crimechk_image->SetValue($warningimage);
}
|
|
|
 |
DonB
|
| Posted: 02/14/2008, 6:59 AM |
|
And going one step farther, I'd suggest putting that into the query in the
datasource:
SELECT CASE IFNULL(somedate,0) WHEN 0 THEN 'thenullimage.gif' ELSE
'theotherimage.gif' END FROM sometable WHERE somecriteria
Since a NULL has no value, it can't be compared directly so I convert it to
a 0. Then the CASE returns one image or the other if somedate is null or
not. Now you have data for a regular image control with no event code
needed. This can be extended to include multiple WHEN terms and multiple
images being return, if that's required.
--
DonB
"datadoit" <datadoit@forum.codecharge> wrote in message
news:fp1jkc$mir$1@news.codecharge.com...
> kirchaj wrote:
>> MamboBrown,
>>
>> The field(s) in question are all date fields. What I really need to know
>> is if
>> the date exists. If it exists then one image needs to be displayed. If
>> the date
>> does not exist, then I need to display a different image. What I am
>> doing is creating a status page for our students to know if they have
>> completed all of their tasks. Green is good, red is bad sort of thing.
>> But
>> most of our fields are dates indicating they turned the appropriate
>> "stuff" in.
>>
>> Any help would be greatly appreciated.
>>
>> TK
>> ---------------------------------------
>
> In that case you can just check the field for a value:
>
> if ($Container->crimechk->GetValue()) {
> $Container->crimechk_image->SetValue($goodimage);
> }
> else {
> $Container->crimechk_image->SetValue($warningimage);
> }
|
|
|
 |
kirchaj
Posts: 215
|
| Posted: 02/15/2008, 8:30 AM |
|
Thanks MamboBrown and DonB for you help.
Mambo, your solution is working great and is doing what I need for now. DonB, I need to get my head around your solution and I will then give it a try.
Your help as well as CodeCharge always makes me look good and gets the job done quickly.
Thanks Again.
TK
|
 |
 |
|