Posts Tagged ‘css3’

Strange Airport : Princess Juliana Airport and Maho Beach

Maho Beach is located on the Dutch side of the Caribbean island of Saint Martin. If you love watching airplanes takeoff and land, this should be your next holiday destination, because sitting right next to the Maho Beach is the busy Princess Juliana International Airport. Aircrafts approaching the airport comes from the direction of the sea and because they must touch down as close as possible to the beginning of runway 10 due to its short length, the aircraft on their final approach flies over the beach at minimal altitude.

You can lie on the beach and watch the underbelly of a 747 thundering within a few dozen yards over your head; the blast from the jet engine blowing sand and belongings all over the place. The thrilling approaches and ease of access for shooting spectacular images makes the airport one of the world’s favorite places among plane spotters.

Watching airliners pass over the beach is such a popular activity that daily arrivals and departures airline timetables are displayed on a board in most bars and restaurants on the beach, and the Sunset Beach Bar and Grill has a speaker on its outside deck that broadcasts the radio transmissions between pilots and the airport’s control tower.

This slideshow requires JavaScript.

Photo creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto creditPhoto credit


Text-overflow CSS

Sometimes text will have to be clipped. For instance when it overflows the element’s box. When this happens, you want to leave a visual “hint” to the user that text has been clipped. This is were the text-overflow-props come in. The most common way to use it is the ellipsis character: “…” although, as the spec says, “the actual character representation may vary”. Opera supports this as well using it’s vendor prefix: -o-text-overflow.

Support for these features is very limited at the moment, WebKit only supports the short-hand text-overflow, and even that is only partly implemented. text-overflow: ellipsis-word; and text-overflow: inherit; don’t work yet. Internet Explorer, funnily enough, supports this too in IE6 and up, according to the MSDN page about it.

The following two divs contains the following text: “Lorem ipsum dolor sit amet, consectetur”. As you can see, it is clipped. The first uses text-overflow: ellipsis;, the second uses text-overflow: clip;.



Text-shadow, Photoshop like effects using CSS

CSS3 finally eliminates the need for Photoshop when all you want to do is a simple shadow. The text-shadow property is used as follows:

text-shadow: 2px 2px 2px #000;

This produces the text with a shadow 2px right and below of the text, which blurs for 2px.

RGBA colors CSS

CSS3 has added a new feature to color setting. Next to rgb you can now also use rgba. The “a” in this
property-name stands, for, you guessed it: alpha. This new feature allows us to specify an opacity value for a color. This one could
make life for webdevelopers a lot easier…

So far, this has only been implemented in Safari 3, and works in the latest Firefox 3 pre-alpha’s.

See the example:

See the difference in the code between the first row, which uses RGBA color values, and the second, which uses RGB values:

<div style="background: rgba(255, 0, 0, 0.2);"></div> <div style="background: rgba(255, 0, 0, 0.4);"></div> <div style="background: rgba(255, 0, 0, 0.6);"></div> <div style="background: rgba(255, 0, 0, 0.8);"></div> <div style="background: rgba(255, 0, 0, 1) ;"></div>

And the second one:

<div style="background: rgb(243, 191, 189);"></div> <div style="background: rgb(246, 143, 142);"></div> <div style="background: rgb(249, 95 , 94) ;"></div> <div style="background: rgb(252, 47, 47) ;"></div> <div style="background: rgb(255, 0, 0) ;"></div>


Opacity CSS

The most widely implemented feature of CSS3 up till now is opacity. It’s probably also the one people have been waiting for the most…

See the example:

See the difference in the code between the first row, which uses the same color value for each row, combined with an opacity value, and the second, which uses RGB values:

<div style=" background: rgb(255, 0, 0) ; opacity: 0.2;"></div> <div style=" background: rgb(255, 0, 0) ; opacity: 0.4;"></div> <div style="background: rgb(255, 0, 0) ; opacity: 0.6;"></div> <div style="background: rgb(255, 0, 0) ; opacity: 0.8;"></div> <div style="background: rgb(255, 0, 0) ; opacity: 1;"></div>

And the second one:

<div style=" background: rgb(243, 191, 189) ; "></div> <div style="background: rgb(246, 143, 142) ; "></div> <div style=" background: rgb(249, 95 , 94) ; "></div> <div style=" background: rgb(252, 47, 47) ;"></div> <div style=" background: rgb(255, 0, 0) ; "></div>

The exact same effect shown here can be reached using rgba values.

Modifiers in regular expression patterns in php

preg_match is used to perform a regular expression match.

if you want to match patterns across multiple lines then you need to use PCRE modifiers.
$str = 'Test
the following code will not work for multiple lines
if (preg_match('/^multi$/', $str))
 echo 'Matched';
You need the following code for multiple lines
if (preg_match('/^multi$/m', $str))
 echo 'Matched';

m (PCRE_MULTILINE) modiefier:

By default, PCRE treats the subject string as consisting of a single “line” of characters (even if it actually contains several newlines). The “start of line” metacharacter (^) matches only at the start of the string, while the “end of line” metacharacter ($) matches only at the end of the string, or before a terminating newline (unless D modifier is set). This is the same as Perl. When this modifier is set, the “start of line” and “end of line” constructs match immediately following or immediately before any newline in the subject string, respectively, as well as at the very start and end. This is equivalent to Perl’s /m modifier. If there are no “\n” characters in a subject string, or no occurrences of ^ or $ in a pattern, setting this modifier has no effect.


Count clicks the right way! in PHP – A Simple Page Click Count System Using PHP And MySQL
Step 1: Set Up Your MySQL Server And PHP Pages

In order to track clicks on a Web page, you need to use a server-side scripting language (e.g., PHP) and a server-side data store (e.g., MySQL). Fortunately, most Web hosts offer both.

Most Web hosts also use cPanel, or something very similar, to let you set up your Web site’s services, including MySQL. And for this exercise, you’re going to need a MySQL database, so it’s time to go ahead and set one up if you don’t already have one.


Your Web host should provide you with a MySQL server name, user name and password. You’ll need this information to do this project. This login information may be the same as your FTP login information, but it’s probably different. Again, check with your Web host.

You need to create a database on the MySQL server, if you don’t already have one. Your Web host may have already done this for you; check with them. If not, cPanel (or whatever interface you were given to manage your site) should have a way for you to create a database. Again, check with your host if you need help with this, as all servers are different.

A final note: In addition to needing to set up a MySQL database for your site, you need to make any page you wish to count a PHP page. HTML pages will not work.

Usually, this is as simple as changing your pages’ file extensions from .htm / .html to .php. In other words, if your home page is named index.html, changing its name to index.php should be enough to get it to work as a PHP page.

Again, you need to change the file extensions of every page you want counted to be .php.

Step 2: Create The MySQL Table

Once you have changed all your file extensions and created the MySQL database you will use, you need to add a table to the database. This table will actually store the page counts.

If your Web host offers MySQL, it almost certainly offers phpMyAdmin, which is a Web interface to manage your database. If you have cPanel, phpMyAdmin is probably located there; otherwise, check with your Web host for how to access phpMyAdmin.

Open up phpMyAdmin, select the database you just created from the menu on the left, click the SQL tab, paste the code below into the box, and click the Go button.

CREATE TABLE click_count (

     page_url VARCHAR(255) NOT NULL,
     page_count INT UNSIGNED NOT NULL,

After phpMyAdmin reports the table has been created, you should see it appear on the left, under your database name. We’re done; you can close out phpMyAdmin and move back into Dreamweaver for Step 3.

Step 3: Add The PHP Code

A page click counter is a fairly straightforward programming problem:

  • Check to see if this is the first visit by this person to this page. We don’t want to increment the current page’s click counter if the user refreshes the page, we only want to increment it if someone comes from someplace else.
  • If this isn’t a refresh, check the database to see if there is a click count for the current page.
  • If there is no click count for the current page create one for this page and set its count to 1.
  • If there is a click count for the current page, get the current count, add one, set that to be the new click count for the page and update the database.

We’ll accomplish this with the following PHP code, which should appear at the very top of each page you want counted, before the DOCTYPE declaration:


//MySQL database variables
//You need to change these variables to be right for your MySQL install
$host = "localhost";
$user = "user";
$pass = "pass";
$dbname = "databasename";
//start a PHP session
//this prevents spamming the click count by refreshing the page
//create current page constant
$curPage = $_SERVER['PHP_SELF'];
//set number of clicks variable to 0
$clicks = 0;
//do not recount if page currently loaded
if($_SESSION['page'] != $curPage) {
     //set current page as session variable
     $_SESSION['page'] = $curPage;
     //try to connect to MySQL server
     if(!$link = mysql_connect($host, $user, $pass)) {
          echo "Could not connect to MySQL server. Check your login information; the MySQL server may also be offline or temporarily overloaded.";
     //try to select database
     elseif(!mysql_select_db($dbname)) {
          echo "Cannot select database.";
     else {
          //get current click count for page from database;
          //output error message on failure
          if(!$rs = mysql_query("SELECT * FROM click_count WHERE page_url = '$curPage'")) {
               echo "Could not parse click counting query.";
          //if no record for this page found,
          elseif(mysql_num_rows($rs) == 0) {
               //try to create new record and set count for new page to 1;
               //output error message if problem encountered
               if(!$rs = mysql_query("INSERT INTO click_count (page_url, page_count) VALUES ('$curPage', 1)")) {
                    echo "Could not create new click counter for this page.";
               else {
                    $clicks = 1;
          else {
               //get number of clicks for page and add 1
               $row = mysql_fetch_array($rs);
               $clicks = $row['page_count'] + 1;
               //update click count in database;
               //report error if not updated
               if(!$rs = mysql_query("UPDATE click_count SET page_count = $clicks WHERE page_url = '$curPage'")) {
                    echo "Could not save new click count for this page.";
Step 4: Displaying The Count

When the code above executes properly, it creates a variable named $clicks which contains the current page click count.

We can display this count anywhere we like on the page, by calling a simple echo command:

<?php echo $clicks; ?>