Monday, October 8, 2007

Conceptual design for site's layout

This post explains how to organize the HTML code to design index.php page's layout using the default.css file created previously; (for other informations about this argument see this post about the website structure, and this post about the page's layout using CSS).

Step 1: HTML code
First step, we create a file called index.php in the site root; in the previous post we have added a link to CSS file (default.css) in the index.php <head> tag and now, we use it to create the page's layout structure wich will be like this:



All pages will be loaded into main section using URL variables. Open index.php and copy and paste this code into the <body> tag:

<body>
<div id="container">
<div id="topbar"> ...topbar content... </div>
<div id="navbar"> ...navbar content... </div>
<!-- the main section where all pages will be loaded using URL variables and PHP include() function -->
<div id="main">
<div id="column_left"> ...column left content... </div>
<div id="column_right"> ...column right content... </div>
<!-- this layer solve some issue about the css design, forced the #main layer height equal to height of two column layer (#columnt_left and #column_right) inside itself -->
<div class="spacer"></div>
<!-- close #main content -->
</div>
<!-- close #container -->
</div>
</body>


Step 2: CSS file

Copy and paste this code into default.css file:

/* ------------------------------
PAGE STRUCTURE
------------------------------ */

/*
#container has an absolute width (780 pixel)
The width of inner elements is set to auto,
in this way all inner elements have the same
width of the element which contains them
*/

#container{width:780px; margin:0 auto;}
#topbar{width:auto; display:block; height:80px;}
#navbar{width:auto; display:block; height:24px;}

#main{width:auto; display:block;}
#column_left{width:560px; margin-right:20px; float:left;}
#column_right{width:200px; float:left;}

/*
div.spacer, solve an issue with #container height
in css 2 column layout.
*/

div.spacer{clear:both; height:10px; display:block;}

#footer{width:auto; display:block; height:24px;}


The graphic result will be like this:




Now, our site structure is ready to be completed adding other elements that we will see in the next lessons.

Sunday, October 7, 2007

Design page layout using CSS

Today's lesson will explains how to design page's layout for your site using a css file. In the previous lesson we have seen a typical website structure which we can use to project our site. In the css folder create a new css file called default.css where insert the css code to design the page's elements.

Now, open index.php and put this code into <head> tag:

<link href="css/default.css" rel="stylesheet" type="text/css" />




In this way index.php will get all informations about the page's design from the CSS file default.css

Page layout and CSS code
Before you proceed, it's useful to have an idea about page's sections. I suggest to use this layout (2 column fixed size):




Copy and paste this code into default.css file:

/* ------------------------------
PAGE STRUCTURE
------------------------------ */

/*
#container has an absolute width (780 pixel)
The width of inner elements is set to auto,
in this way all inner elements have the same
width of the element which contains them
*/

#container{width:780px; margin:0 auto;}
#topbar{width:auto; display:block; height:80px;}
#navbar{width:auto; display:block; height:24px;}

#main{width:auto; display:block;}
#column_left{width:560px; margin-right:20px; float:left;}
#column_right{width:200px; float:left;}

/*
div.spacer, solve an issue with #container height
in css 2 column layout.
*/

div.spacer{clear:both; height:10px; display:block;}

#footer{width:auto; display:block; height:24px;}


The basic page structure is ready! In the next lesson we will format index.php file, adding layer using default.css file.

Related Posts
Optimize CSS files to improve code readability

Saturday, October 6, 2007

Config.php: define your database connection's parameters

In this lesson we will create a new MySQL database using phpMyAdmin and a config.php file in the site root with connection's parameters for the database (database name, database host, username, password).



Open config.php and copy and paste the code replacing the value of variables $db_host, $db_name, $username, $password, with correct parameters.

<?php
// Connection's Parameters
$db_host="localhost";
$db_name="database_name";
$username="database_username";
$password="database_password";
$db_con=mysql_connect($db_host,$username,$password);
$connection_string=mysql_select_db($db_name);
// Connection
mysql_connect($db_host,$username,$password);
mysql_select_db($db_name);
?>


Now, in the site root, create index.php file and use PHP include() function to include config.php into the page.

<?php include('config.php') ?>




This is a simple way to enstablish a connection with your database MySQL to be used when you need to execute a SQL query.
The index.php structure will be explained in the next lessons.

Friday, October 5, 2007

A typical website structure

This is a typical website structure that I use in my web projects. To create this structure using Dreamweaver, select from the menu the option Windows > Files and start creating new pages and folders.



- index.php is the "container" of your site. Inside this page we will define the page's principal sections (topbar, navigation's bar, main content, footer);

- config.php contains the connection's strings for MySQL database (host name, user, password);

- image folder contains all the graphical elements for your site (gif, jpeg, png);

- css folder contains the style sheets files (.css);

- include folder contains all the web pages that will be loaded into the index.php "main content" section using URL variables.

See also: Load pages using URL variables and PHP include() function

Thursday, October 4, 2007

Set up Your Workspace

In this first post I want to introduce you how to set up a workspace to design and manage your web projects using Dreamweaver (for coding), MySql (database) and PHP (server-side language).



Before you begin you need a software to edit web pages, a software to manipulate image, a local web server to test PHP pages, and a database where to store all data.

Dreamweaver
I think Dreamweaver is the best solution to design and edit code for your website. The current version, CS3, is easier to use, and more powerful than the previous version, but it has a rather elevated price ($399). You can download a trial copy from the Adobe website.

Photoshop / The GIMP
To create graphical elements for your pages I suggest to use Photoshop or The GIMP. The GIMP is a open source software to manipulate images, it's free and available for Win, Mac and Linux operating systems.

Server and Database
To manage you server locally and to test your website written with PHP, you can download and install Apache. To store data install MySQL database and phpMyAdmin to create and manage MySQL database.

Mac User?
If you are a Mac user, I suggest to use MAMP to configure your local webserver, MySQL and phpMyAdmin. It's simple, fast and free.

Wednesday, October 3, 2007

Tutorials and resources: the best of woork

The following list is the table of contents of all tutorials you can find on woork. Tutorials are about web programming, web design, css, frameworks, database and other related topics.

The Woork Handbook

Download the Woork Handbook, it's Free!
The Woork Handbook is a free eBook about CSS, HTML, Ajax, web programming, Mootools, Scriptaculous and other topics about web design... directly from Woork!

HTML 5 Visual Cheat Sheet
HTML 5 Visual Cheat Sheet is an useful cheat sheet for web designers and developers designed by me. This cheat sheet is essentially a simple visual grid with a list of all HTML tags and of their related attributes supported by HTML versions 4.01 and/or 5. The simple visual style I used to design this sheet allows you to find at a glance everything you are looking for.


Introduction to design websites


CSS, HTML, Web design


Twitter API



Ajax / Frameworks / Web 2.0


News Tickers



MooTools Lessons



Database


PHP Functions and Scripts


Coldfusion Functions and Scripts

Javascript Functions


Web Applications


Blogger Tips and Hack


Frequent Asked Questions


Spreadsheets, Project Management Tools and Resources


Other Links

Freebies

The most interesting free resources on-line: fonts, icons, brushes for Photoshop and Illustrator, Dreamweaver extensions, Blogger and WordPress Templates and much more!

Do you want to suggest an interesting resource? Please send me a message.


5 Beautiful penstyle fonts(October 5, 2008)
I'm always looking for new interesting fonts. This is a list of some of my favourite penstyle fonts you can download and use on your design projects.
Read More...

The Daily Inspired Blogger template(October 4, 2008)
Are you a Blogger fanatic? Are you looking for a professional Blogger Template magazine-style? Now you can download The Daily Inspired template for free!
Read More...

10 Beautiful icons set for web developers and designers (September 18, 2008)
This post contains a collection of 10 beautiful and very popular icons set useful to be used in your web applications or your websites.
Read More

10 Fonts to design original logos (September 5, 2008)
Are you a designer looking for nice fonts to design high quality logos? Take a look at these 10 free fonts you might use to design impressive logos for your customers.
Read more...

Beautiful and free social websites icon set for bloggers (August 29, 2008)
A beautiful and free icon set of the most popular social websites "in a bottle" to use in your blog (delicious, technorati, magnolia, feed rss, facebook, twitter, digg, StumbleUpon, design float, reddit)
Read more...

10 Awesome typewriter fonts for web designers (August 23, 2008)
This is a list of my preferred Typewriter fonts I often use in my design projects. Some of this fonts are very popular and absolutely you must have them in your fonts collection! I included a link to download each font apart and some suggest about how you can use them.
Read more...

10 Handwritten fonts you can't miss (August 12, 2008)
This is a list of my preferred Handwritten fonts I often use in my design projects. I included a link to download each font apart and some suggest about how you can use them.
Read more...