With SOPA, PIPA, and ACTA still looming, I have been coming across lots of ways to gain access to websites during a government shutdown of the internet. Everything from dial-up modems to creating a mesh wireless network for communicating with others. In the event of a DNS shutdown, all sites that have a dedicated IP address will still be reachable. All you have to do is enter the IP. Here’s an emergency list of IP’s for such a situation:
HTML Colors
What do those html hex values for colors actually mean? Well, I intend to explain it as clearly as possible right here. HTML colors aren’t supposed to be complex or confusing. The hex values are six digits following a (#) sign. The six digits are actually 3 pairs of digits. Each pair represents either Red, Green, or Blue (RGB). The lowest value that a pair can get is 00. The highest value that a pair can get is FF. So, #000000 is the lowest RGB value possible. #00FF33 has the lowest possible value for Red (first pair), the highest possible value for Green (second pair), and the value “33″ for Blue (third pair).
Color Values
| Color | Color HEX | Color RGB |
|---|---|---|
| #000000 | rgb(0,0,0) | |
| #FF0000 | rgb(255,0,0) | |
| #00FF00 | rgb(0,255,0) | |
| #0000FF | rgb(0,0,255) | |
| #FFFF00 | rgb(255,255,0) | |
| #00FFFF | rgb(0,255,255) | |
| #FF00FF | rgb(255,0,255) | |
| #C0C0C0 | rgb(192,192,192) | |
| #FFFFFF | rgb(255,255,255) |
With all three colors allowing values from 0 to 255, there are a total of 16 Million colors. I know this isn’t anything ground breaking, but I have found that while many people are familiar with the #FFFFFF hex notation, very few actually know what the hex values mean and how to use that information to tweak colors.
Below is a nice color chart to help you find most of the hex values you’ll need for web sites:
| Primary/Main/Basic Colors | |||||
| 000000 | 000033 | 000066 | 000099 | 0000CC | 0000FF |
| 003300 | 003333 | 003366 | 003399 | 0033CC | 0033FF |
| 006600 | 006633 | 006666 | 006699 | 0066CC | 0066FF |
| 009900 | 009933 | 009966 | 009999 | 0099CC | 0099FF |
| 00CC00 | 00CC33 | 00CC66 | 00CC99 | 00CCCC | 00CCFF |
| 00FF00 | 00FF33 | 00FF66 | 00FF99 | 00FFCC | 00FFFF |
| 330000 | 330033 | 330066 | 330099 | 3300CC | 3300FF |
| 333300 | 333333 | 333366 | 333399 | 3333CC | 3333FF |
| 336600 | 336633 | 336666 | 336699 | 3366CC | 3366FF |
| 339900 | 339933 | 339966 | 339999 | 3399CC | 3399FF |
| 33CC00 | 33CC33 | 33CC66 | 33CC99 | 33CCCC | 33CCFF |
| 33FF00 | 33FF33 | 33FF66 | 33FF99 | 33FFCC | 33FFFF |
| 660000 | 660033 | 660066 | 660099 | 6600CC | 6600FF |
| 663300 | 663333 | 663366 | 663399 | 6633CC | 6633FF |
| 666600 | 666633 | 666666 | 666699 | 6666CC | 6666FF |
| 669900 | 669933 | 669966 | 669999 | 6699CC | 6699FF |
| 66CC00 | 66CC33 | 66CC66 | 66CC99 | 66CCCC | 66CCFF |
| 66FF00 | 66FF33 | 66FF66 | 66FF99 | 66FFCC | 66FFFF |
| 990000 | 990033 | 990066 | 990099 | 9900CC | 9900FF |
| 993300 | 993333 | 993366 | 993399 | 9933CC | 9933FF |
| 996600 | 996633 | 996666 | 996699 | 9966CC | 9966FF |
| 999900 | 999933 | 999966 | 999999 | 9999CC | 9999FF |
| 99CC00 | 99CC33 | 99CC66 | 99CC99 | 99CCCC | 99CCFF |
| 99FF00 | 99FF33 | 99FF66 | 99FF99 | 99FFCC | 99FFFF |
| CC0000 | CC0033 | CC0066 | CC0099 | CC00CC | CC00FF |
| CC3300 | CC3333 | CC3366 | CC3399 | CC33CC | CC33FF |
| CC6600 | CC6633 | CC6666 | CC6699 | CC66CC | CC66FF |
| CC9900 | CC9933 | CC9966 | CC9999 | CC99CC | CC99FF |
| CCCC00 | CCCC33 | CCCC66 | CCCC99 | CCCCCC | CCCCFF |
| CCFF00 | CCFF33 | CCFF66 | CCFF99 | CCFFCC | CCFFFF |
| FF0000 | FF0033 | FF0066 | FF0099 | FF00CC | FF00FF |
| FF3300 | FF3333 | FF3366 | FF3399 | FF33CC | FF33FF |
| FF6600 | FF6633 | FF6666 | FF6699 | FF66CC | FF66FF |
| FF9900 | FF9933 | FF9966 | FF9999 | FF99CC | FF99FF |
| FFCC00 | FFCC33 | FFCC66 | FFCC99 | FFCCCC | FFCCFF |
| FFFF00 | FFFF33 | FFFF66 | FFFF99 | FFFFCC | FFFFFF |
| Secondary/Mixed/Pastel Colors | ||||||
| FF4848 | FF68DD | FF62B0 | FE67EB | E469FE |
D568FD
|
9669FE
|
| FF7575 | FF79E1 | FF73B9 | FE67EB | E77AFE |
D97BFD
|
A27AFE
|
| FF8A8A | FF86E3 | FF86C2 | FE8BF0 | EA8DFE | DD88FD | AD8BFE |
| FF9797 | FF97E8 | FF97CB | FE98F1 | ED9EFE | E29BFD | B89AFE |
| FFA8A8 | FFACEC | FFA8D3 | FEA9F3 | EFA9FE | E7A9FE | C4ABFE |
| FFBBBB | FFACEC | FFBBDD | FFBBF7 | F2BCFE | EDBEFE | D0BCFE |
| FFCECE | FFC8F2 | FFC8E3 | FFCAF9 | F5CAFF | F0CBFE | DDCEFF |
| FFDFDF | FFDFF8 | FFDFEF | FFDBFB | F9D9FF | F4DCFE | E6DBFF |
| FFECEC | FFEEFB | FFECF5 | FFEEFD | FDF2FF | FAECFF | F1ECFF |
| FFF2F2 | FFFEFB | FFF9FC | FFF9FE | FFFDFF | FDF9FF | FBF9FF |
|
800080
|
872187
|
9A03FE
|
892EE4
|
3923D6
|
2966B8
|
23819C
|
|
BF00BF
|
BC2EBC
|
A827FE
|
9B4EE9
|
6755E3
|
2F74D0
|
2897B7
|
|
DB00DB
|
D54FD5
|
B445FE
|
A55FEB
|
8678E9
|
4985D6
|
2FAACE
|
|
F900F9
|
DD75DD
|
BD5CFE
|
AE70ED
|
9588EC
|
6094DB
|
44B4D5
|
| FF4AFF | DD75DD | C269FE |
AE70ED
|
A095EE | 7BA7E1 | 57BCD9 |
| FF86FF | E697E6 | CD85FE | C79BF2 | B0A7F1 | 8EB4E6 | 7BCAE1 |
| FFA4FF | EAA6EA | D698FE | CEA8F4 | BCB4F3 | A9C5EB | 8CD1E6 |
| FFBBFF | EEBBEE | DFB0FF | DBBFF7 | CBC5F5 | BAD0EF | A5DBEB |
| FFCEFF | F0C4F0 | E8C6FF | E1CAF9 | D7D1F8 | CEDEF4 | B8E2EF |
| FFDFFF | F4D2F4 | EFD7FF | EDDFFB | E3E0FA | E0EAF8 | C9EAF3 |
| FFECFF | F4D2F4 | F9EEFF | F5EEFD | EFEDFC | EAF1FB | DBF0F7 |
| FFF9FF | FDF9FD | FEFDFF | FEFDFF | F7F5FE | F8FBFE | EAF7FB |
|
5757FF
|
62A9FF
|
62D0FF | 06DCFB | 01FCEF | 03EBA6 | 01F33E |
|
6A6AFF
|
75B4FF
|
75D6FF | 24E0FB | 1FFEF3 | 03F3AB | 0AFE47 |
|
7979FF
|
86BCFF | 8ADCFF | 3DE4FC | 5FFEF7 | 33FDC0 | 4BFE78 |
| 8C8CFF | 99C7FF | 99E0FF | 63E9FC | 74FEF8 | 62FDCE | 72FE95 |
| 9999FF | 99C7FF | A8E4FF | 75ECFD | 92FEF9 | 7DFDD7 | 8BFEA8 |
| AAAAFF | A8CFFF | BBEBFF | 8CEFFD | A5FEFA | 8FFEDD | A3FEBA |
| BBBBFF | BBDAFF | CEF0FF | ACF3FD | B5FFFC | A5FEE3 | B5FFC8 |
| CACAFF | D0E6FF | D9F3FF | C0F7FE | CEFFFD | BEFEEB | CAFFD8 |
| E1E1FF | DBEBFF | ECFAFF | C0F7FE | E1FFFE | BDFFEA | EAFFEF |
| EEEEFF | ECF4FF | F9FDFF | E6FCFF | F2FFFE | CFFEF0 | EAFFEF |
| F9F9FF | F9FCFF | FDFEFF | F9FEFF | FDFFFF | F7FFFD | F9FFFB |
| 1FCB4A | 59955C | 48FB0D | 2DC800 | 59DF00 | 9D9D00 | B6BA18 |
| 27DE55 | 6CA870 | 79FC4E | 32DF00 | 61F200 | C8C800 | CDD11B |
| 4AE371 | 80B584 | 89FC63 | 36F200 | 66FF00 | DFDF00 | DFE32D |
| 7CEB98 | 93BF96 | 99FD77 | 52FF20 | 95FF4F | FFFFAA | EDEF85 |
| 93EEAA | A6CAA9 | AAFD8E | 6FFF44 | ABFF73 | FFFF84 | EEF093 |
| A4F0B7 | B4D1B6 | BAFEA3 | 8FFF6F | C0FF97 | FFFF99 | F2F4B3 |
| BDF4CB | C9DECB | CAFEB8 | A5FF8A | D1FFB3 | FFFFB5 | F5F7C4 |
| D6F8DE | DBEADC | DDFED1 | B3FF99 | DFFFCA | FFFFC8 | F7F9D0 |
| E3FBE9 | E9F1EA | EAFEE2 | D2FFC4 | E8FFD9 | FFFFD7 | FAFBDF |
| E3FBE9 | F3F8F4 | F1FEED | E7FFDF | F2FFEA | FFFFE3 | FCFCE9 |
| FAFEFB | FBFDFB | FDFFFD | F5FFF2 | FAFFF7 | FFFFFD | FDFDF0 |
| BABA21 | C8B400 | DFA800 | DB9900 | FFB428 | FF9331 | FF800D |
| E0E04E | D9C400 | F9BB00 | EAA400 | FFBF48 | FFA04A | FF9C42 |
| E6E671 | E6CE00 | FFCB2F | FFB60B | FFC65B | FFAB60 | FFAC62 |
| EAEA8A | F7DE00 | FFD34F | FFBE28 | FFCE73 | FFBB7D | FFBD82 |
| EEEEA2 | FFE920 | FFDD75 | FFC848 | FFD586 | FFC48E | FFC895 |
| F1F1B1 | FFF06A | FFE699 | FFD062 | FFDEA2 | FFCFA4 | FFCEA2 |
| F4F4BF | FFF284 | FFECB0 | FFE099 | FFE6B5 | FFD9B7 | FFD7B3 |
| F7F7CE | FFF7B7 | FFF1C6 | FFEAB7 | FFEAC4 | FFE1C6 | FFE2C8 |
| F9F9DD | FFF9CE | FFF5D7 | FFF2D2 | FFF2D9 | FFEBD9 | FFE6D0 |
| FBFBE8 | FFFBDF | FFFAEA | FFF9EA | FFF7E6 | FFF4EA | FFF1E6 |
| FEFEFA | FFFEF7 | FFFDF7 | FFFDF9 | FFFDF9 | FFFEFD | FFF9F4 |
| D1D17A | C0A545 |
C27E3A
|
C47557
|
B05F3C
|
C17753
|
B96F6F
|
| D7D78A | CEB86C | C98A4B |
CB876D
|
C06A45
|
C98767
|
C48484 |
| DBDB97 | D6C485 | D19C67 | D29680 |
C87C5B
|
D0977B
|
C88E8E |
| E1E1A8 | DECF9C | DAAF85 | DAA794 | CF8D72 | DAAC96 | D1A0A0 |
| E9E9BE | E3D6AA | DDB791 | DFB4A4 | D69E87 | E0BBA9 | D7ACAC |
| EEEECE | EADFBF | E4C6A7 | E6C5B9 | DEB19E | E8CCBF | DDB9B9 |
| E9E9C0 | EDE4C9 | E9D0B6 | EBD0C7 | E4C0B1 | ECD5CA | E6CCCC |
| EEEECE | EFE7CF | EEDCC8 | F0DCD5 | EACDC1 | F0DDD5 | ECD9D9 |
| F1F1D6 | F5EFE0 | F2E4D5 | F5E7E2 | F0DDD5 | F5E8E2 | F3E7E7 |
| F5F5E2 | F9F5EC | F9F3EC | F9EFEC | F5E8E2 | FAF2EF | F8F1F1 |
| FDFDF9 | FDFCF9 | FCF9F5 | FDFAF9 | FDFAF9 | FCF7F5 | FDFBFB |
|
F70000
|
B9264F
|
990099
|
74138C
|
0000CE
|
1F88A7
|
4A9586
|
| FF2626 |
D73E68
|
B300B3
|
8D18AB
|
5B5BFF”
|
25A0C5
|
5EAE9E |
| FF5353 | DD597D | CA00CA |
A41CC6
|
7373FF
|
29AFD6 | 74BAAC |
| FF7373 | E37795 | D900D9 | BA21E0 | 8282FF | 4FBDDD | 8DC7BB |
| FF8E8E | E994AB | FF2DFF | CB59E8 | 9191FF | 67C7E2 | A5D3CA |
| FFA4A4 | EDA9BC | F206FF | CB59E8 | A8A8FF | 8ED6EA | C0E0DA |
| FFB5B5 | F0B9C8 | FF7DFF | D881ED | B7B7FF | A6DEEE | CFE7E2 |
| FFC8C8 | F4CAD6 | FFA8FF | EFCDF8 | C6C6FF | C0E7F3 | DCEDEA |
| FFEAEA | F8DAE2 | FFC4FF | EFCDF8 | DBDBFF | D8F0F8 | E7F3F1 |
| FFEAEA | FAE7EC | FFE3FF | F8E9FC | EEEEFF | EFF9FC | F2F9F8 |
| FFFDFD | FEFAFB | FFFDFF | FFFFFF | FDFDFF | FAFDFE | F7FBFA |
Have you ever tried to create a nice grid of MySQL results before? Perhaps something 4 items across and 4 items down with pagination for more than 16 results? Well, let’s go ahead and build that here so you can learn how to do it! Using tables for this is tricky and ugly. I don’t recommend it. We will be using some very straight forward PHP and CSS for this! Okay, this tutorial is not difficult to follow if you are familiar with PHP and MySQL. If you are brand new to PHP and/or MySQL, you should familiarize yourself with them by going through some more basic tutorials first! This tutorial also assumes that you have access to a web server that is running PHP 5.x and MySQL server. One last disclaimer…this tutorial doesn’t cover securing any of this stuff. I will likely create another tutorial in the future for keeping your stuff secure. So, be warned, none of what I’m giving you here is secured!
First, let’s look at the basic HTML and CSS that make this work:
<style type="text/css">
#dataGrid{
width: 800px;
margin: auto;
}
.thumb{
width: 150px;
height: 100px;
float: left;
clear: none;
margin: 5px;
background: #ccc;
}
</style>
<div id="dataGrid">
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
<div class="thumb"></div>
</div>
Okay, let’s get into the details. We need a database. I’m calling mine dbGallery. Using phpMyAdmin, or another MySQL client, create your new database and name it whatever you want. Now, inside of the dbGallery database, I’m going to create a table called tblPhotos. Again, call yours whatever you like. tblPhotos is going to have the following fields: photoID(int 11), photoName(varchar 30), category(varchar 20), active(int 1). Make sure to set photoID as the primary key and also set it to auto-increment! Next we need to add some photos to tblPhotos. So, let’s create a nice script that will make this more automated. In your web root, create a new folder called galleryScripts. In the galleryScripts folder, create a new PHP file called mysqlConnect.php and give it the following contents:
<?php
$db_host = ""; //put your hostname in the quotes
$db_username = ""; //put your username in the quotes
$db_pass = ""; //put your password in the quotes
$db_name = "dbGallery"; //change dbGallery to whatever your db is called
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");
?>
Now, back in the web root, create a folder called galleryPhotos. Also in the web root, create a new PHP file called addPhotos.php and give it the following contents:
<?php
include "galleryScripts/mysqlConnect.php";
//Parser for Add Photo Form
if (isset($_POST["photoName"])){
$photoName = mysql_real_escape_string($_POST["photoName"]);
$category = mysql_real_escape_string($_POST["category"]);
//add photo to db
$sql = mysql_query("
INSERT INTO
tblPhotos (
photoName,
category,
active
)VALUES(
'$photoName',
'$category',
'1'
)") or die(mysql_error());
$pid = mysql_insert_id();
$newname = "$pid.jpg";
move_uploaded_file($_FILES['fileField']['tmp_name'],"galleryPhotos/$newname");
header("location: addPhotos.php");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Photos</title>
</head>
<body>
<h3>Add New Photo</h3>
<form action="addPhotos.php" enctype="multipart/form-data" name="myForm" id="myForm" method="post">
Photo Name: <input name="photo_name" type="text" id="photoName" size="64" /><br />
Category: <input name="category" type="text" id="category" size="64" /><br />
Upload Image (jpg only):
<label>
<input type="file" name="fileField" id="fileField" />
</label>
<label>
<input type="submit" name="button" id="button" value="Add Photo" />
</label>
</form>
</body>
</html>
And now, in your web root, create a new PHP file called gallery.php and give it the following contents:
<?php
//connect to db
include "galleryScripts/mysqlConnect.php";
//check for a page number. If not, set it to page 1
if (!(isset($_GET['pagenum']))){
$pagenum = 1;
}else{
$pagenum = $_GET['pagenum'];
}
//query for record count to setup pagination
$data = mysql_query("SELECT * FROM tblPhotos WHERE active = 1");
$rows = mysql_num_rows($data);
//number of photos per page
$page_rows = 16;
//get the last page number
$last = ceil($rows/$page_rows);
//make sure the page number isn't below one, or more than last page num
if ($pagenum < 1){
$pagenum = 1;
}elseif ($pagenum > $last){
$pagenum = $last;
}
//Set the range to display in query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//get all of the photos
$dynamicList = "";
$sql = mysql_query("SELECT * FROM tblPhotos WHERE active = 1 $max");
//check for photos
$photoCount = mysql_num_rows($sql);
if ($photoCount > 0){
while($row = mysql_fetch_array($sql)){
$photoID = $row["photoID"];
$photoName = $row["photoName"];
$category = $row["category"];
$dynamicList .= '
<div class="thumb">
<a href="photo.php?id=' . $photoID . '"><img class="clip" src="galleryPhotos/' . $photoID . '.jpg" alt="' . $photoName . '" width="175" border="0" /></a>
</div>
';
}
}else{
$dynamicList = "There are no photos at this time!";
}
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tech Remedy Grid Gallery Demo</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
echo '<p style="text-align:center; font-weight:bold;">Page ' . $pagenum . ' of ' . $last . '</p>';
if ($pagenum == 1){
echo '<div class="pagination" align="center"><ul>';
}else{
echo '<div class="pagination" align="center"><ul><li><a href="' . $_SERVER['PHP_SELF'] . '?pagenum=1">« first</a></li>';
$previous = $pagenum-1;
}
//check if number of pages is higher than 1
if($last != 1){
//Loop from 1 to last page to create page number links
for($i = 1; $i <= $last; $i++){
echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?pagenum=' . $i . '">' . $i . '</a></li>';
}
}
if ($pagenum == $last){
echo '</div>';
}else{
$next = $pagenum+1;
echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?pagenum=' . $last . '">last »</a></li></ul></div>';
}
?>
<div id="dataGrid">
<?php echo $dynamicList; ?>
</div>
</body>
</html>
Okay, we are ready to start adding some photos to our gallery! Open a browser and navigate to your addPhotos.php file. Fill out the form and add a photo. Repeat the process until you have added several photos. Make sure to add more than 16 if you want to see the pagination working!
Now, if you go to gallery.php in your browser, your images should be displayed in a vertical list. It doesn’t look all that great. So, let’s create a CSS file that will make the images appear in a grid and clip them to all fit real nicely! In the web root, create a new CSS file called style.css and give it the following contents:
#dataGrid{
width: 800px;
margin: auto;
}
.thumb{
width: 175px;
height: 100px;
float: left;
clear: none;
margin: 5px;
}
.clip {
position: absolute;
clip:rect(0px 175px 100px 0px);
}
.pagination{
padding: 2px;
}
.pagination ul{
margin: 0;
padding: 0;
text-align: center;
font-size: 16px;
}
.pagination li{
list-style-type: none;
display: inline;
padding-bottom: 1px;
}
.pagination a, .pagination a:visited{
padding: 0 5px;
border: 1px solid #9aafe5;
text-decoration: none;
color: #2e6ab1;
}
.pagination a:hover, .pagination a:active{
border: 1px solid #2b66a5;
color: #000;
background-color: #FFFF80;
}
Now, just navigate to your gallery.php file in your browser and you should see a nice paginated grid of photos! All of the photos links are broken though! Let’s fix that. Create a new PHP file called photo.php and give it the following contents:
<?php
//connect to db
include "galleryScripts/mysqlConnect.php";
//initialize some vars
$photoID = '';
$photoName = '';
//check what photo we are looking for
if(isset($_GET['id'])){
$photoID = mysql_real_escape_string($_GET['id']);
//get the photo
$sql = mysql_query("SELECT * FROM tblPhotos WHERE photoID='$photoID' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$photoName = $row['photoName'];
$category = $row['category'];
}
}else{
echo 'No photo was selected!';
exit();
}
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tech Remedy Gallery Demo - <?php echo $photoName; ?></title>
</head>
<body>
<div id="photo">
<img src="galleryPhotos/<?php echo $photoID; ?>.jpg" alt="<?php echo $photoName; ?>" width="400" /><br />
<h2><?php echo $photoName; ?></h2>
<p><?php echo $category; ?></p>
</div>
</body>
</html>
And that’s it! Now, when you click on a photo in your gallery it will take you to a page that nicely displays your photo along with some photo information. Pretty cool, huh?
Let me know in the comments if you come across any problems!
After working with Adobe ColdFusion for about a month now, I have to say that I’m really impressed. I had this expectation that it would leave me longing for my beloved PHP. It’s actually a very cool server side language that allows for insanely fast development of dynamic web applications! I know, I sound like a commercial…so, let’s start with the negatives of ColdFusion just so you know I’m not getting paid by Adobe or something!
First, ColdFusion is very proprietary. In order to use it, the web server must have Adobe’s ColdFusion Server software installed and running. That software isn’t free. Many web hosts don’t bother with it for this reason…why pay for ColdFusion when PHP is free? I get that…there is an open source alternative called Railo and it is pretty good too! Unfortunately, trying to convince your web host to install this is a different story!
The next negative aspect of ColdFusion is that it is overly simplified. For example, there is only one loop tag. CFLOOP is your only option! There are different parameters to set what kind of loop it is, but this causes confusion when reading over someone else’s code. In PHP it is always very clear what kind of loop I’m looking at. If it’s a while loop, it says ‘while’.
So, the CFLOOP tag was supposed to make things easier. You only need to remember one LOOP tag and then just set the parameters for the loop to determine what kind of loop it will be.
Now, what I LOVE about ColdFusion how elegantly it interacts with SQL databases! So much can be done with very little code and that makes for insanely fast development! Let’s look at a comparison of a simple SQL query with some output in both PHP and ColdFusion. First, in PHP:
<?php
//connect to db
mysql_connect("localhost","username","password") or die ("Failed to connect to mysql");
mysql_select_db("databaseName") or die ("database not found!");
//check url for id variable
if (isset($_GET['id'])){
$id = $_GET['id];
$sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$product_name = $row["product_name"];
$product_details = $row["product_details"];
$product_price = $row["product_price"];
}
}else{
echo "No product was selected!";
exit();
}
mysql_close();
//dynamic output
$output = '
<table>
<tr>
<th>Product Name</th>
<th>Product Details</th>
<th>Product Price</th>
</tr>
<tr>
<td>' . $product_name . '</td>
<td>' . $product_details . '</td>
<td>' . $product_price . '</td>
</tr>
</table>';
?>
<html>
<body>
<?php echo $output; ?>
</body>
</html>
Next, let’s look at the exact same thing done in ColdFusion:
<!---Check url for id variable--->
<cfif isDefined url.id>
<cfquery name="products" datasource="store">
SELECT *
FROM products
WHERE id = '#url.id#'
LIMIT 1
</cfquery>
<cfelse>
<cfoutput>No Product Was Selected!</cfoutput>
<cfabort>
</cfif>
<!---Dynamic Output--->
<html>
<body>
<table>
<tr>
<th>Product Name</th>
<th>Product Details</th>
<th>Product Price</th>
</tr>
<tr>
<cfoutput query="products">
<td>#product_name#</td>
<td>#product_details#</td>
<td>#product_price#</td>
</cfoutput>
</tr>
</table>
</body>
</html>
The ColdFusion took me half as much time to write as the PHP and it works just as well. So, overall, I am very impressed with ColdFusion. A lot of my web developer friends talk crap about ColdFusion, and that’s okay…Most of them have never actually developed with it, so I take those opinions with a giant grain of salt!
Keep on the lookout for some ColdFusion Tutorials in the near future!
In ColdFusion, it can get a little confusing to know when you should and should not wrap your variables in the # symbol. Here’s a little reference that helps me:
When To #:
- Within a string
- Within CFOUTPUT
- Within CFQUERY
- In the CFDUMP var attribute
- When Referencing an Array or List as a Parameter
When Not To #:
- Within a CFSET
- Within a CFIF
- ANYWHERE ELSE
This is a helpful reference for any web developer. Let me know if I missed any!
Math Symbols Supported by HTML
| Character | Entity Number | Entity Name | Description |
|---|---|---|---|
| ∀ | ∀ | ∀ | for all |
| ∂ | ∂ | ∂ | part |
| ∃ | ∃ | ∃ | exists |
| ∅ | ∅ | ∅ | empty |
| ∇ | ∇ | ∇ | nabla |
| ∈ | ∈ | ∈ | isin |
| ∉ | ∉ | ∉ | notin |
| ∋ | ∋ | ∋ | ni |
| ∏ | ∏ | ∏ | prod |
| ∑ | ∑ | ∑ | sum |
| − | − | − | minus |
| ∗ | ∗ | ∗ | lowast |
| √ | √ | √ | square root |
| ∝ | ∝ | ∝ | proportional to |
| ∞ | ∞ | ∞ | infinity |
| ∠ | ∠ | ∠ | angle |
| ∧ | ∧ | ∧ | and |
| ∨ | ∨ | ∨ | or |
| ∩ | ∩ | ∩ | cap |
| ∪ | ∪ | ∪ | cup |
| ∫ | ∫ | ∫ | integral |
| ∴ | ∴ | ∴ | therefore |
| ∼ | ∼ | ∼ | similar to |
| ≅ | ≅ | ≅ | congruent to |
| ≈ | ≈ | ≈ | almost equal |
| ≠ | ≠ | ≠ | not equal |
| ≡ | ≡ | ≡ | equivalent |
| ≤ | ≤ | ≤ | less or equal |
| ≥ | ≥ | ≥ | greater or equal |
| ⊂ | ⊂ | ⊂ | subset of |
| ⊃ | ⊃ | ⊃ | superset of |
| ⊄ | ⊄ | ⊄ | not subset of |
| ⊆ | ⊆ | ⊆ | subset or equal |
| ⊇ | ⊇ | ⊇ | superset or equal |
| ⊕ | ⊕ | ⊕ | circled plus |
| ⊗ | ⊗ | ⊗ | cirled times |
| ⊥ | ⊥ | ⊥ | perpendicular |
| ⋅ | ⋅ | ⋅ | dot operator |
Greek Letters Supported by HTML
| Character | Entity Number | Entity Name | Description |
|---|---|---|---|
| Α | Α | Α | Alpha |
| Β | Β | Β | Beta |
| Γ | Γ | Γ | Gamma |
| Δ | Δ | Δ | Delta |
| Ε | Ε | Ε | Epsilon |
| Ζ | Ζ | Ζ | Zeta |
| Η | Η | Η | Eta |
| Θ | Θ | Θ | Theta |
| Ι | Ι | Ι | Iota |
| Κ | Κ | Κ | Kappa |
| Λ | Λ | Λ | Lambda |
| Μ | Μ | Μ | Mu |
| Ν | Ν | Ν | Nu |
| Ξ | Ξ | Ξ | Xi |
| Ο | Ο | Ο | Omicron |
| Π | Π | Π | Pi |
| Ρ | Ρ | Ρ | Rho |
| undefined | Sigmaf | ||
| Σ | Σ | Σ | Sigma |
| Τ | Τ | Τ | Tau |
| Υ | Υ | Υ | Upsilon |
| Φ | Φ | Φ | Phi |
| Χ | Χ | Χ | Chi |
| Ψ | Ψ | Ψ | Psi |
| Ω | Ω | Ω | Omega |
| α | α | α | alpha |
| β | β | β | beta |
| γ | γ | γ | gamma |
| δ | δ | δ | delta |
| ε | ε | ε | epsilon |
| ζ | ζ | ζ | zeta |
| η | η | η | eta |
| θ | θ | θ | theta |
| ι | ι | ι | iota |
| κ | κ | κ | kappa |
| λ | λ | λ | lambda |
| μ | μ | μ | mu |
| ν | ν | ν | nu |
| ξ | ξ | ξ | xi |
| ο | ο | ο | omicron |
| π | π | π | pi |
| ρ | ρ | ρ | rho |
| ς | ς | ς | sigmaf |
| σ | σ | σ | sigma |
| τ | τ | τ | tau |
| υ | υ | υ | upsilon |
| φ | φ | φ | phi |
| χ | χ | χ | chi |
| ψ | ψ | ψ | psi |
| ω | ω | ω | omega |
| ϑ | ϑ | ϑ | theta symbol |
| ϒ | ϒ | ϒ | upsilon symbol |
| ϖ | ϖ | ϖ | pi symbol |
Other Entities Supported by HTML
| Character | Entity Number | Entity Name | Description |
|---|---|---|---|
| Œ | Œ | Œ | capital ligature OE |
| œ | œ | œ | small ligature oe |
| Š | Š | Š | capital S with caron |
| š | š | š | small S with caron |
| Ÿ | Ÿ | Ÿ | capital Y with diaeres |
| ƒ | ƒ | ƒ | f with hook |
| ˆ | ˆ | ˆ | modifier letter circumflex accent |
| ˜ | ˜ | ˜ | small tilde |
|   |   | en space | |
|   |   | em space | |
|   |   | thin space | |
| | ‌ | ‌ | zero width non-joiner |
| | ‍ | ‍ | zero width joiner |
| | ‎ | ‎ | left-to-right mark |
| | ‏ | ‏ | right-to-left mark |
| – | – | – | en dash |
| — | — | — | em dash |
| ‘ | ‘ | ‘ | left single quotation mark |
| ’ | ’ | ’ | right single quotation mark |
| ‚ | ‚ | ‚ | single low-9 quotation mark |
| “ | “ | “ | left double quotation mark |
| ” | ” | ” | right double quotation mark |
| „ | „ | „ | double low-9 quotation mark |
| † | † | † | dagger |
| ‡ | ‡ | ‡ | double dagger |
| • | • | • | bullet |
| … | … | … | horizontal ellipsis |
| ‰ | ‰ | ‰ | per mille |
| ′ | ′ | ′ | minutes |
| ″ | ″ | ″ | seconds |
| ‹ | ‹ | ‹ | single left angle quotation |
| › | › | › | single right angle quotation |
| ‾ | ‾ | ‾ | overline |
| € | € | € | euro |
| ™ | ™ | ™ | trademark |
| ← | ← | ← | left arrow |
| ↑ | ↑ | ↑ | up arrow |
| → | → | → | right arrow |
| ↓ | ↓ | ↓ | down arrow |
| ↔ | ↔ | ↔ | left right arrow |
| ↵ | ↵ | ↵ | carriage return arrow |
| ⌈ | ⌈ | ⌈ | left ceiling |
| ⌉ | ⌉ | ⌉ | right ceiling |
| ⌊ | ⌊ | ⌊ | left floor |
| ⌋ | ⌋ | ⌋ | right floor |
| ◊ | ◊ | ◊ | lozenge |
| ♠ | ♠ | ♠ | spade |
| ♣ | ♣ | ♣ | club |
| ♥ | ♥ | ♥ | heart |
| ♦ | ♦ | ♦ | diamond |
I have been coming across a lot of “Essential Tools For Web Developers” lists lately and I noticed that they are all really extensive. Some of them have as many as 100 tools listed! This begs the question, “Do you understand what ‘essential’ means?”. So here is my EXTENSIVE list of essential tools for web developers. This is literally every essential tool you will need to develop web applications.
Web Server Software and Extensions
First and foremost, you’re going to need a web server. If you have a web host, disregard this tool because this is essentially the service that they provide. If you plan to run your own web server, check out WAMP for Windows and LAMP for Linux.
Text Editor
Notepad will work. However, I would recommend getting a better one than that since it doesn’t really have any features! There are a ton of free options. Some people swear by Eclipse. I prefer Notepad++ on Windows, TextWrangler on Mac, and VIM on Linux.
FTP Client
After you have created a new script or app using your awesome text editor, you will have to upload it to the web server. Again, there are several free FTP clients out there. I prefer FileZilla personally. It was originally written for Windows, but has since been ported to Mac and Linux. The Mac version can be a tad buggy from time to time but it’s super fast still and I love it!
Ummmm…yeah…that’s it. Nothing else is needed to develop web applications. There are lots of helpful tools out there and they should certainly be used, but they are NOT essential!
Hi Everyone! I wanted to post a very basic tutorial series on using PHP and MySQL. This tutorial is Part 1 and it will not focus on anything complicated, rather it will break down the process of connecting to your MySQL database. This tutorial assumes that you know how to create a MySQL database and it also assumes that you have web hosting with PHP and MySQL installed. For MySQL database management, I personally prefer using phpMyAdmin. Some people prefer other MySQL clients, while some hardcores prefer doing all of their database management from within their PHP script. I’ll leave the decision as to which method you’ll use up to you.
We will be using the following database throughout this entire tutorial series, so don’t delete it after you complete this tutorial! You’ll need it for Part 2 and so on!
Now, the first thing we need to do is create a database. So, using whatever method you prefer, create a database called “test_data” (without the quotes) and give it one table called “test_table” with 3 fields. The first field should be labeled “id”, and it should be set to INT, Auto-Increment, and set it as the primary key. The second field should be labeled “name”, and it should be set to VARCHAR with a length of 32. The third field should be labeled “city”, and it should be set to VARCHAR with a length of 64.
Okay, so now we have our database and table all set up! So, the next thing we need to do is create our PHP script! Open a good text editor such as Notepad++, Dreamweaver, etc. The first thing we need to do is create a PHP code block. Here’s how it should look:
<?php ?>
Next, we need to establish a connection to the database. We do this using the mysql_connect function that is built in to PHP. You will need to know the hostname of your MySQL server, as well as the username and password for the database. Typically, the hostname is “localhost”.
<?php
//connect to mysql database server
mysql_connect("hostname","username","password");
?>
Replace hostname with your actual hostname, username with your actual username, and password with your actual password. This code attempts to connect to your database with the credentials that you provided. The problem is, there is nothing in place to inform you if your script was successful or not! So, we will need to add some error handling.
<?php
//connect to mysql database server
mysql_connect("hostname","username","password") or die (mysql_error());
?>
Now, if you get an error, then there is something wrong with your connection script. If nothing happens at all, that means the connection is successful!
Next, we will want to make this script a little cleaner and add some code that will tell you if the connection to the database was successful or not. So we will want to create three variables at the top of our script. db_host, db_user, and db_pass. We will also create an echo for a successful database connection.
<?php $db_host = ""; //place your hostname in this variable $db_user = ""; //place your username in this variable $db_pass = ""; //place password in this variable //connect to mysql database server mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error()); echo "Successfully connected to MySQL Database!"; ?>
Now that our script is connecting to our MySQL server, we just need to tell it which database we want to use. Do this using the mysql_select_db function in PHP. So, we will add one more variable at the top of our script called db_name. We will add the mysql_select_db function at the bottom of the script with an echo for a successful selection. You will notice that the success message is dynamic which will allow you to use it on other scripts without changing the code.
<?php $db_host = ""; //place your hostname in this variable $db_user = ""; //place your username in this variable $db_pass = ""; //place password in this variable $db_name = ""; //place your database name in this variable //connect to mysql database server mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error()); echo "Successfully connected to MySQL Database!"; //Select Database mysql_select_db($db_name) or die (mysql_error()); echo '<h2>Successfully selected ' . $db_name . ' database!</h2>'; ?>
And there you have it! A perfectly respectable MySql connection script! The next tutorial will focus on the basic while loop for pulling data from the database!
by Tom Duffy
Every Christmas, my wife and I make gifts for people rather than buying them…it isn’t that we’re cheap, we just love to make things. This year, we decided that she would make custom dish towels and I would make a color changing solar lantern. Here’s a video of the final lantern:
Now, just so you know up front…I didn’t “make” the color changing solar part of this project…I just took an affordable and existing product and modified the casing.
Materials Needed
- 3/16″ Diameter Wood Dowels
- 4″x4″ Blank Wood Coasters from Michael’s
- Pack of 2 Garden Creations Color Changing Solar Yard Lights
- A Dremel or other quick cutting tool
- 200 Grit Sandpaper
- Thin Natural Fabric – from fabric store
- Sewing Machine
- Electric Drill
- Wood Glue
- A Pencil
- Flat Black Spray Paint
SAFETY WARNING
Any time that you are using power tools you need to be careful. Make sure that you have a safe work area and always wear eye protection. Personally, I prefer these safety glasses from PlugsSafety. They actually have built in ear plugs which help when you’re in a small area with noisy equipment and tools! Also, I’m not responsible if you hurt yourself or others while doing this project. Just use common sense and you’ll be fine.
Step 1 – Preparing The Solar Light
The first thing we need to do is remove the part that we want from the yard light.
We just want the top solar part which is also attached to the LED. Carefully twist the solar top counter-clockwise until it unlocks from the bottom piece.
It should now look like this:
Now would be a good time to mention that I ordered 5 pairs of these solar yard lights. Of the 10 total lights, only 3 of them actually worked out of the box. I discovered that of the 7 that failed, 4 of them had drained batteries and 3 of them still failed after a full charge on the batteries. So, I unscrewed the housing and had a look inside. All three of them had the same problem…the solder had broken free between the switch and the battery leads. I re-soldered them and sealed them back up.
Step 2 – Preparing the Base
The base of the lantern starts with the 4″x4″ blank wooden coasters that I got from Michael’s. They start out looking like this:
The first thing that you will want to do is give the whole piece a nice sanding with the 200 grit sandpaper. If you are really picky about finish, you can then go over it again with some 600 grit automotive sandpaper to make it really smooth! Next, you want to outline the shape of the solar top with pencil onto the coaster. I had a bunch of these and I know how to solder, so I just removed the LED housing from one and cut the wires:
Next, we will mark where we want to drill our pilot holes that our wooden dowels will slide into. I didn’t really need to measure since we actually DON’T want it to be exact. We aren’t going to be using anything but tension to hold the top piece onto the dowels, so our lack of accuracy in this step actually keeps the top piece securely in place!
Next we drill! The dowels are 3/16″ in diameter, so I used an 11/64″ drill bit. Go ahead and drill straight down all the way through where we marked our coaster.
Step 3 – Preparing the Dowels
Next, we are going to cut our wood dowels to the correct length. Here’s the dowels that I used:
The length that I used is 5″, but this can easily be changed…just remember that whatever length you use, you will need to adjust the size of your fabric wrap accordingly! I started out using my dremel to cut the dowels to size, but found later in the process that wire cutters were a lot quicker. Wire cutters also pinch the ends of the dowels a little, which makes it a lot easier to push them into the pilot holes in our base.
Step 4 – Getting The Dowels in Place
Next, just push the dowels into the pilot holes until they just start to appear from the bottom of the base…don’t let them actually poke through though.
Next, turn the whole thing over so the base is on top and let the dowels act like table legs. Add one or two drops of wood glue to each hole on top of the dowel. I personally let wood glue dry overnight, but if you are confident that it is dry before then, go ahead and move on to the next step when you are ready.
Step 5 – Preparing The Fabric Wrap
Okay, this part is hard unless you know how to sew or know someone who does! I don’t know the first thing about sewing, so my wife handled this part like a champion! Basically, the wrap will have a circumference of 13 1/2″ and the height is entirely dependent on your dowel length. All you really need to keep in mind is that when all is said and done, there should be 1/4″ of dowel sticking up above the wrap after it is in place. My wife managed to create a nice seam on both the top and the bottom to keep things nice and neat. Here she is hard at work:
And the finished wrap:
Step 6 – Put it All Together
Next, slide the wrap over the dowels and make sure that all sides are pushed all the way down flush with the base. Next, push the dowels that are protruding from the top of the wrap into the corners of the solar housing.
Step 7 – Paint it!
Next, remove the solar top and the fabric wrap. Go over all of the wood again with sandpaper to make sure it is nice and smooth. Place the piece base down on some newspaper in a well ventilated area. I wore rubber gloves for this part because you will have to touch the paint. Spray an even coat over all of the exposed wood. Grab the end of one of the dowels and flip the piece over so it is resting on the dowels like a table. Spray an even coat over the base. Let the paint dry for 24 hours. Apply more coats if needed. That’s it! You’re done! Now try it out!
Feel free to comment if you have any questions or if you get stuck on any of the steps. I wish I had better photo documentation of everything, but I did the best I could. I plan to make several more of these, so if there is a particular step that many people want photos of, just let me know and I’ll make sure to get some pictures. Thanks for reading!
There seems to be a lot of confusion out there regarding the structure of the Linux File System. Why are certain programs located in /bin while others are in /sbin or /usr/bin? Why can I save files in one directory and not another? How can I tell where I should save my files and programs? Well, I hope to assist in clearing all of that up today!
First, let’s take a look at a graphical representation of the Linux File System:
The first thing we need to talk about is the root directory (/). It is the directory where all of the other directories in the file system are stored. The root user is the only one who can write to this directory. It is not to be confused with /root which is the root user’s home directory!
Within the root directory, you will find the following sub-directories. I have included some descriptions of each:
1. /bin
The /bin directory is for User Binaries. It is where many of the most common Linux commands are stored. Specifically, this is where the single user mode binaries are stored.
2. /sbin
This directory is almost exactly like the /bin directory, with one exception. The binaries here are primarily used by Administrators for system maintenance.
3. /etc
The configuration files for your programs and operating system are stored in /etc.
4. /dev
This is where all of the device files are located. For example, this is the directory that you would call to in order to mount a drive with a command like: mount /dev/sda2 /mnt/backup
5. /proc
The /proc directory is one of the most interesting in the whole Linux File System. It is actually its own virtual file system with a massive amount of text information about system processes.
6. /var
This is where all of the variable files are stored. Most commonly, this is where log files and web server files are stored.
7. /tmp
These are simply temporary files.
8. /usr
Programs installed by single users get stored here.
9. /home
This is where all of the user home directories are except for the root user’s home directory which is /root.
10. /boot
The files that make up the boot loader go in /boot. Everything from boot loader menus, to the actual kernel files are stored here.
11. /lib
All of the binary files that are located in /bin and /sbin are supported by the library files located in /lib.
12. /opt
/opt is short for “optional”. It is the directory where individual vendors can install optional add-on software for the operating system.
13. /mnt
The /mnt directory is the mount point that system administrators can use to mount file systems temporarily.
14. /media
The /media directory serves the same purpose as the /mnt directory except it is specifically for removable devices and can be used by non administrators.
15. /srv
The /srv directory contains server specific service files.


































Recent Discussion