TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-16-2009, 02:05 PM   #1 (permalink)
The Visitor
 
Join Date: Mar 2009
Posts: 4
Thanks: 0
deanr201 is on a distinguished road
Default 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.

Last edited by deanr201 : 03-17-2009 at 08:56 AM.
deanr201 is offline  
Reply With Quote
Old 03-16-2009, 05:36 PM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

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.
__________________

Village Idiot is offline  
Reply With Quote
Old 03-16-2009, 10:09 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

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);
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 03-17-2009, 01:15 AM   #4 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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. ;)
delayedinsanity is offline  
Reply With Quote
Old 03-17-2009, 01:41 AM   #5 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Yeah, I don't even know what the problem the OP was having?
allworknoplay is offline  
Reply With Quote
Old 03-17-2009, 08:45 AM   #6 (permalink)
The Visitor
 
Join Date: Mar 2009
Posts: 4
Thanks: 0
deanr201 is on a distinguished road
Default

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.
deanr201 is offline  
Reply With Quote
Old 03-17-2009, 03:59 PM   #7 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by deanr201 View Post

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...
allworknoplay is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tips to Improve Your Coding and Projects Village Idiot Tips & Tricks 45 12-03-2012 07:46 AM
Writing Clean Code Village Idiot Tips & Tricks 10 06-25-2012 12:35 PM
help with object code planepixel Absolute Beginners 12 02-03-2009 01:38 PM
Views on transferring code ownership jcorradino General 4 12-05-2008 11:04 AM
Snipply.com - Code snippet website codyodell Show Off 27 04-13-2008 02:09 PM


All times are GMT. The time now is 06:42 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design