TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Looking for a solution, Have some code, but need a little more help! (http://www.talkphp.com/absolute-beginners/4046-looking-solution-have-some-code-but-need-little-more-help.html)

deanr201 03-16-2009 02:05 PM

Looking for a solution, Have some code, but need a little more help!
 
*edit re added my problem, sorry for the confusion*

As mentioned in my introduction thread, I'm a designer and not a coder, but have started to expand into the coding thing.

I have a use for calendar script and I wasnt sure where to start so after a bit of googling found a script released under GNU but it did not fit my purpose 100%.

as it stood the script would display a calender and allow me to have a "free" day in one colour and a "busy" day in another, only I needed 3 colours for the free day.

The code does write the calender out into a table, and the following is where the status is set.
PHP Code:

if ($date_status!="1") {
                                
$status_color "669900";
                                
$js_status "0";
                            }

                            
$output .= "<td id=\"$year"."-"."$fmonth"."-"."$fstartdate\" width=$width valign=top align=center onclick=\"calendar_date('$year"."-"."$fmonth"."-"."$fstartdate','$js_status','$username','669900');\" bgcolor=\"#$status_color\"> 

Ideally I need to be able to specify what the colour is via variable, as the code for viewing the calender is.

PHP Code:

require "calendar.php";
echo (
'<div style="float:left; margin:3px">');
print 
calendar("2009""1","user1",1,0);
echo (
'</div>'); 

this would display on the page a single calender for January 2009.


***Partial Solution***
Since this I have managed to get a partial solution which is to was to add in the following.

PHP Code:

                            if ($date_status!="1") {
 switch (
$season):
    case 
"l":
        
$status_color="99CC66";
        break;
    case 
"m":
        
$status_color="FFCC33";
        break;
    case 
"h":
        
$status_color="FF6600";
        break;
    default:
        
$status_color="669900";
endswitch;
$js_status "0";                            }

                            
$output .= "<td id=\"$year"."-"."$fmonth"."-"."$fstartdate\" width=$width valign=top align=center onclick=\"calendar_date('$year"."-"."$fmonth"."-"."$fstartdate','$js_status','$username','669900');\" bgcolor=\"#$status_color\"> 

and on the page to view the calender.

PHP Code:

require "calendar.php";
echo (
'<div style="float:left; margin:3px">');
print 
calendar("2009""1","user1",1,0,"l");
echo (
'</div>'); 

where "l" is the relates to Low, Medium, High, which are defined in the calenders code, this allows me to display more than one calender month on the view page, and display the month with the colour for either "low" "Medium" or "high" colour scheme.

I'm not sure this is the most effective way of achieving this but it works.

Village Idiot 03-16-2009 05:36 PM

Its generally a good idea to leave both the problem and solution in tact. Reason for that is if you had this problem, you are not the first or last, this thread could help someone else.

Wildhoney 03-16-2009 10:09 PM

How about the following? It looks a little more elegant than a huge switch statement. Village Idiot is also right; please do not remove your questions as it could well help other people in the future.

php Code:
$iDateStatus       = 2;
$aStatusColours     = array('FFFFFF', '000000', 'CCCCCC', '669900');
$szStatusColour     = null;

if ($iDateStatus != null) /* != "1"? */
{
    $szStatusColour =   isset($aStatusColours[$iDateStatus])  ?
                        $aStatusColours[$iDateStatus]       :
                        null;
}

printf("Colour is: %s", $szStatusColour);

delayedinsanity 03-17-2009 01:15 AM

Take it from me, probably the op of the longest talking to himself thread on TalkPHP, sometimes it helps to leave the question for your own purposes in addition to providing a resource for others. ;)

allworknoplay 03-17-2009 01:41 AM

Yeah, I don't even know what the problem the OP was having?

deanr201 03-17-2009 08:45 AM

Thanks for the replys. My sorry for removing it if I had been thinking a bit more clear I wouldn't of needed to post in the first place! :)

Original problem and how I solved it in the first post, if any one can recommend a better solution I'd be interested to see how it could be made better.

allworknoplay 03-17-2009 03:59 PM

Quote:

Originally Posted by deanr201 (Post 22249)

where "l" is the relates to Low, Medium, High, which are defined in the calenders code, this allows me to display more than one calender month on the view page, and display the month with the colour for either "low" "Medium" or "high" colour scheme.

I'm not sure this is the most effective way of achieving this but it works.

Ok I understand now. Yeah, go ahead and use what you figured out. I'm sure there are many ways to go about it but if it works then go for it.

I don't see any right or wrong ways to do it....and it's simple enough...


All times are GMT. The time now is 05:00 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0