Showing posts with label Graphic and Design. Show all posts
Showing posts with label Graphic and Design. Show all posts

Saturday, November 7, 2009

How to use PHP include

If you have a website with plenty of pages to update, to edit each page and change it one by one will be very tedious and boring things to do. The more page you have, the more possibility that you make mistakes. Using PHP include is certainly something you need and it is very helpful because not only it enables you to uniform certain parts of your content pages, but also update them all by only editing a single file.

Before you start using PHP includes, make sure that your web host or server can handle PHP files. Secondly, when you are using PHP includes on any pages, make sure the extension of those page is “.php” instead of “.html”. By using this PHP include script, once uploaded to the web, all of your files will merge appropriately to form one page.

Here’s how the PHP code looks like:

<?php include("filename.php"); ?>

The code can be pasted into sidebars, header, tables and anywhere you like.

Change the "filename" to anything you like, to make things easier to remember, it is suggested that you give it a name which correlates to the content you will be putting in it. For example if it is “header.php” then the file should be made especially for header. If the file contains advertisements for your site, then you can name it “ads.php”.

Next, you will want to create a page where the content of this page will appear in the page that contains the PHP include code. Make sure you save it with the exact same name you assigned to the code above, otherwise the script wont work.

Sometimes the path names doesn’t work and therefore you need to use alternative way, that is using the URL in the include instead, like this:

<?php include("http://www.domainname.com/directory/filename.php"); ?>

Using this method is less efficient in terms of server resources because (just like a browser) it has to create an HTTP session, get the file and then pull it in (even both of them located at the same server). This method of course is slower than using a pathname.

You can include files with .html, .php, .txt, .asp and other extensions.



Sunday, November 1, 2009

Learn CSS basic codes

CSS stands for Cascading Style Sheets, is a tool to add layout to your websites. It controls the presentation of web pages. CSS provides information to the browser about how the content on the page should be displayed. CSS covers fonts, lines, margins, width, height, advanced positions and background images. It controls layout of many documents from a single style sheet, apply different layout to different media-types (print, screen, etc) and many more. Compared to HTML, CSS offers more options and is supported by all browsers today.

To structure content html is used, but to format structured content, CSS is used. CSS command consists of three parts: selector – property – value.

Selector {property: value; }

Selector comes first, followed by property and then value. Each property and its value is separated by a colon and ended with a semi-colon. They are also have to be surrounded by curly brackets. Example:

body {background-color: red;}

Selector: what html element applied in this area
Property: what will be changed to the selector.
Value: the value of what you are going to change.
Note: Don't leave spaces between property value and the units. It only works in IE but not in Opera or Firefox.

CSS can be applied in 3 ways to an html document:
  • by using the html attribute style (inline) – example:

    <body style="background-color: yellow;">
  • By inserting the CSS codes between style tag (<style>) – example:

    <html>
    <head>
    <title>Example</title>
    <style type="text/css">
    body {background-color: yellow;}
    </style>
    </head>
  • By inserting the CSS codes in an external style sheet (a text file with the extension “.css”) and linked to the html document. The link can be created with a line of html code that is inserted in the header section of your html file (between <head> and </head> tag):

    <link rel="stylesheet" type="text/css" href="name-of-the-folder/name-of-the-file.css" />
We will look at the one which is the most preferred and widely used: external (the last option above). To understand how it works, you can simply copy and paste each of two of the following codes into a separate notepad and save one as “.htm” and the other as “.css” file but keep both files in the same directory or folder:



Save this to "mypage.htm":Save this to "style.css":
<html>
<head>
<title>My Page</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Hello, I’m Edy Bright</h1>
</body>
</html>

body {

  background-color: red;

}

Open the .htm file by double-click it and you will see that the css file will effect the other file in terms of layout or design. You can change the CSS file to update the style of all HTML documents that linking to it.

Some other common CSS coding:

Properties and Values:

Colors and background
color:green; - (choose the color)
background-color:#ff0000; - (choose background color)
background-image:url("mypic.gif"); - (background image)
background-repeat:no-repeat;/repeat;/repeat-x;/repeat-y; - (image background pattern)
Background-attachment:scroll/ fixed - (whether still image or movable)
background-position:2cm 2cm/ 50% 25%/ top right - (image background position)

Font
font-family:"Times New Roman", serif; - (what types of font will be used, a comma appears between alternate values, it means if the browser can’t find Times New Roman, it loads Serif). A comma can also separate multiple selectors.
font-style:italic;/ oblique; - (font style)
font-variant:small-caps;/ normal; - (font variant)
font-weight:bold;/ normal; - (font weight)
font-size:30px;/ 12pt;/ 120%;/1em; - (font size)

Text
text-indent:30px; - (text indent)
text-align:right;/ center;/ justify; - (text align)
text-decoration:underline;/ overline;/ line-through; - (add a line in the text)
letter-spacing:6px; - (space between letters)
text-transform:uppercase;/ lowercase;/ none;
list-style-type:circle;/ square;/ upper-roman; - (list item markers)
p:first-letter{color:#ff0000;font-size:xx-large;} – (to change the first letter of a paragraph)
p:first-line {color:#0000ff;font-variant:small-caps;} –(to change the first line of a paragraph).


Margin, Padding, Border
margin-top/ right/ bottom/ left: 100px; - (position of the margin)
or margin:100px 40px 10px 70px; - (clock-wise= top, right, bottom, left)
padding:20px 20px 20px 80px; - (padding= space between the border and content)
border-width:thick;/ thin;/medium;
border-style:dotted;/ dashed;/ solid;/ double;/ groove;/ ridge;/ inset;/ outset;
border-style:dotted solid double dashed; - (adding different border style from top-right-bottom-left/ clock-wise direction)
border-top/ left/ bottom-color:red; -(apply a color to only one side of a border)
border-bottom/ top/ right-style:solid; -(add style to only one side of a border)
border-top/ left/ bottom-width:thick; -(set the size of a border)
outline:green dotted thick; - (a line drawn around elements (outside the borders).
outline-color:#00ff00;/ style:dotted;/ width:5px;


position:absolute;/ relative; top:150px; left:500px; - (locating an element whether in absolute or relative position)
z-index:1;/2;/3; etc. - (To make an element become layers and the value of its property can be used as an order of which elements overlap one another)

visibility:hidden – (to hide an element, but it still take up the same space as before)
display:none – (to hide an element and it will not take up any space)
max-height:/min-height:/max-width:/min-width:100px; - (set the maximum/ minimum height and width of an element)
display:inline – (to change block element become inline)
display:block – (to change an inline element to a block element)



Selectors:

Link
a:visited - (a visited link)
a:active - (a link the moment it is clicked.)
a:hover - (when you place a cursor over a link)

Class, Id and Div
class="....." - (to specify a style to a particular element or group of elements)
id="....." - (to specify a style for a single, unique element)
span class="....." - (for adding visual features to selected parts of text)
div id="....." - (to group one or more block-level elements)

Comment
/*put your comment here*/ - (you can add comment on top of css coding to explain your code, comments are ignored by browsers)



Colspan and Rowspan in HTML Table

Part 1: HTML
Part 2: HTML Attributes
Part 3: HTML Table
Part 4: Colspan and Rowspan

Colspan and rowspan are html attributes used to span table cells across more than a column or row. Colspan is short for “column span” or indicates “how many across” while a rowspan indicates “how many down”.

Colspan is used within a <td> tag to specify how many columns it should span.
Here, i give you the example:

<table border="1">
<tr>
<td colspan="5">Cell 1-5 combined</td>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
<td>Cell 5</td>
</tr>
</table>

and here is the outcome:
Cell 1-5 combined
Cell 1Cell 2Cell 3Cell 4Cell 5

By setting colspan to "5", the cell in the first row spans five columns. Here below is another example for better understanding:

<table border="1">
<tr>
<td colspan="3">Cell 1-3</td>
<td>Cell A</td>
<td>Cell B</td>
</tr>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
<td>Cell 5</td>
</tr>
</table>

Here when you see in a browser:

Cell 1-3
Cell ACell B
Cell 1Cell 2Cell 3Cell 4Cell 5


Rowspan sets how many rows a cell spans.
Example:

<table border="1">
<tr>
<td rowspan="5">Cell 1-5</td>
<td>Cell 1</td>
</tr>
<tr>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
</tr>
<tr>
<td>Cell 4</td>
</tr>
<tr>
<td>Cell 5</td>
</tr>
</table>

and here the result when you see in the browser:
Cell 1-5Cell 1
Cell 2
Cell 3
Cell 4
Cell 5

Not as hard as you think right?, and with a number of practices, it should get easier and you might get used to it :)


Using HTML codes to create Tables

Part 1: HTML
Part 2: HTML Attributes
Part 3: HTML Table
Part 4: Colspan and Rowspan

Tables are defined with <table> tag and it is made of rows (<tr>) and columns (<td>). Tr means table row and td means table data.

  • To start creating table, you need an opening table tag, which is <table> and to end it, is to use table closing tag which is </table>.
  • To start creating horizontal table rows you need the opening tag <tr> and after entering number of column/s you need to end it with a closing tag </tr>.
  • To start making column in the table, as usual you need the opening tag <td> and after entering all the data, close it with a closing tag which is <td>.

Friday, October 30, 2009

How to add Favicon to Blogger blog

Favicon stands for “favourite icon”, (also known as a bookmark icon, shortcut icon or website icon). It is a 16 X 16 pixels icon which appears next to a website’s URL in the address bar, it also appears next to the page’s title in a tabbed document interface and in bookmarks. Adding a favicon to your own blog is a good way to distinguish your blog from millions of other blogs.

How to add favicon to blog
There are many free online tools which can help you generate a favicon. As for me, i use http://www.html-kit.com/favicon/ for my favicons. When you upload your favicon image to HTML kit’s they will automatically give you two 16 X 16 favicons to download, one is still image and the other one is animated version. You also can create your own image for your favicon from any image manipulation softwares like Gimp or Photoshop, just by selecting the dimension to be 16 X 16. I know there are still many sites that many people recommend to generate a favicon, but i dont have time yet to explore them.

To add favicon to your Blogger:
  • You can upload your favicon image to an external web host, such as Photobucket or your Google Picasa album. Login to your Picasa photo album and Click upload button to upload your image. Once your image is sent, copy the URL by clicking “Link to this photo” on the right side of the screen. To copy your image URL, you also can do it by right-click on the image and select “Copy Image Location”.
  • Login to your Blogger, from the dasboard click Layout and then Edit Html.
  • Perform your back-up.
  • Find the following code:

    </head>
  • Just above the code (or in between <head> and </head> tags), add the following HTML code:

    <link rel="shortcut icon" href="Your-Favicon-Image-URL" >

    or

    <link href='Your-Favicon-Image-Url' rel='shortcut icon' type='image/vnd.microsoft.icon'/>

    Replace the red text above with your favicon image URL. Once you're done, the code should finally appear like this (i take mine for an example):

    <link href='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAK7V9Xnb759Kcso_g_BRPRljqrEBkIqzf3rBY2tGc5QxXihzecnkc4zOx77F9b4iHLb_hRyrBe4f51yuAXAroL7pIuq0NvoZBPQgzRho4L8kz_OO_fWTMXVS37g4J3t36FPRlkS5yvI9n/' rel='shortcut icon' type='image/vnd.microsoft.icon'/>
    </head>
  • Save your template and test.
If the favicon still doesn’t appear, clear your browser’s cache file and restart the browser. After that renavigate to your blog.

Saturday, August 1, 2009

How to Add Images to Yahoo Email

To add an image as an attachment in Yahoo mail probably most of you know how to do it, just click the ‘Attach Files’ button on the Compose Mail page, browse to where you put the image and it will automatically being uploaded. How about if including the picture directly in your message, so that readers will easily view the pictures and the message at the same place without having to bother downloading the images.

In order to do it, first you have to locate your images at any web server. You can upload it to free image hosting service like Picasa web album, Photobucket, ImageShack etc or to your own web host. After that you can insert the pictures from the web in an email, make sure the Yahoo mail rich text editor is enabled.
  • Open your image in a browser, the one you upload to web server.
  • Highlight the image using your mouse and press Ctrl + C (copy). If you right click the image and select "copy image" it doesn't work in Firefox, maybe it works for Internet Explorer. So better to highlight using your mouse and press Ctrl + C.
  • Go to your Yahoo mail, put your cursor inside the email body where you want the picture to show up and then press Ctrl + V (paste). Yahoo has inserted the picture inside the email, you can continue typing your email after or before the image.
  • You can also simply use ‘drag and drop’ to do this as an alternative way.
You can add as many images to your email as you want, but keep in mind that the more graphics you put in your mail, the larger it will become and it is advised that your email should not more than 10Mb (megabytes).

how to insert image to your Yahoo email