Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Community > MacNN Lounge > Help: Making a list of fun PHP projects

Help: Making a list of fun PHP projects
Thread Tools
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status: Offline
Reply With Quote
Jan 29, 2006, 02:56 PM
 
Hey folks,

I've been playing a lot with php recently, and I've really enjoyed it. I was looking around for a list of fun little projects to do in PHP, but I couldn't find one, so I decided to compile one myself, and maybe stick it up on a website somewhere. The eventual goal would be to help php programmers who are just getting started learn a little bit about programming.

So I'm looking for suggestions.
The first I came up with was simple. With graphics, sometimes I want to know what the ratio for scaling would be if I want to make an image smaller or larger, and the missing value. So I wrote a script that took the current height and width, and one of the new values that I wanted to scale to, and it provides the other.

So the first would be something like:
1) Write a script which will calculate the values to scale a graphic with.


Make sense? These ought to be relatively simple projects. Like processing files, performing calculations, etc. There are lots of programs that do little things like my example above, but it wasn't about needing it, it was about doing it to learn. Your help will be much appreciated.
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
     
cla
Mac Enthusiast
Join Date: Mar 2000
Status: Offline
Reply With Quote
Jan 29, 2006, 03:44 PM
 
I read your post three times and still can't figure it out... What exactly do you need help with? :>
     
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status: Offline
Reply With Quote
Jan 29, 2006, 04:15 PM
 
Originally Posted by cla
I read your post three times and still can't figure it out... What exactly do you need help with? :>

Sorry.

I'm looking for ideas for little PHP scripting "challenges". "Write a script that does this..." Something that can be done in a day. A challange for novice PHP writers.
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
     
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 29, 2006, 05:10 PM
 
I'm definitely a PHP-neophyte, but for a client's website I wanted the stylesheets both to change with the seasons automatically - and be user-selectable. So I did some research and came up with this:
[php]<!-- User-defined/seasonal stylesheet - © Dings Produksjoner 2006 -->
<?php
if(date("n") == 12) {
if(date("j") >= 22):
$DefStyle = 'vinter';
echo "<link rel=\"stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />";
else:
$DefStyle = 'host.css';
echo "<link rel=\"stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
endif;
}
if(date("n") >= 1 && date("n") <= 2) {
$DefStyle = 'vinter';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />";
}
if(date("n") == 3) {
if(date("j") <= 21):
$DefStyle = 'vinter';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />";
else:
$DefStyle = 'var';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
endif;
}
if(date("n") >=4 && date("n") <= 5) {
$DefStyle = 'var';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
}
if(date("n") == 6) {
if(date("j") <= 21):
$DefStyle = 'var';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
else:
$DefStyle = 'sommer';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
endif;
}
if(date("n") >= 7 && date("n") <= 8) {
$DefStyle = 'sommer';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
}
if(date("n") == 9) {
if(date("j") <= 21):
$DefStyle = 'sommer';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />
<link rel=\"alternate stylesheet\" href=\"host.css\" type=\"text/css\" title=\"host\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
else:
$DefStyle = 'host';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
endif;
}
if(date("n") >= 10 && date("n") <= 11) {
$DefStyle = 'host';
$AltStyles = "<link rel=\"alternate stylesheet\" href=\"sommer.css\" type=\"text/css\" title=\"sommer\" />
<link rel=\"alternate stylesheet\" href=\"var.css\" type=\"text/css\" title=\"var\" />
<link rel=\"alternate stylesheet\" href=\"vinter.css\" type=\"text/css\" title=\"vinter\" />";
}
?>

<link rel="stylesheet" type="text/css" media="screen" title="Brukerdefinert Stylesheet" href="<?php echo (!$sitestyle)?$DefStyle:$sitestyle ?>.css" />
<?php echo "$AltStyles" ?>[/php]

Don't know if this is the sort of things you are looking for, but I'd figure I'd post it anyway

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status: Offline
Reply With Quote
Jan 29, 2006, 05:32 PM
 
Yes, definately the kind of thing I'm looking for. Except without the answer

2) Write a script that will swap out a style sheet depending on the time of year/season.

Thanks!
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
     
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Jan 29, 2006, 05:37 PM
 
Aha. I also made a request for this (solution which can be found in web developer forum):

3) Write a php-menu that will know what page you are on and "grey" out the menu-item dynamically to avoid recursive links.

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:44 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2