jump to navigation

Naming variables and creating variables August 31, 2008

Posted by Nsh15 in php, Variables and Data.
Tags: , ,
add a comment

Variables r containers that hold information., to make use of  ‘em u need to give ur variable a name then u can start storing information in it. They can hold either number or a string of characters.

A variable can exist or not exist (which mean created or not yet) and it can hold information or not hold information (which means that u already had created it but this is not necessary means that u have gave it a value); these are two independent ideas. For example: if u bought a cup then it exist but it if empty this doesn’t mean that it does not exist , but in case it’s not empty for sure it exist.

A variable keeps its information for the whole script not only for a PHP section.

Naming variables:

U have more than a millions of options when u decide to select a variable name, there are some few conditions, such as:

1. it should start with dollar sign $

2. it can include letters, numbers and underscore only

3. it can start with a letter or underscore nor a number

u should also notice that:

1. variable name is case sensitive, i.e… uppercase not the same as lowercase letters

2. variables can be any length

3. its recommended that that ur name to be descriptive, i.e… let the name make a sense in order to let human and programmer understand the code and debug it easily

4. Some variables consist of more than one word, it’s a personal style to decide how to connect the words, but in general there are two public methods:

First method: connect the words using underscore (_)

Second method: using uppercase to denote the beginning of new words

Example: the variable family name can be wither family_name or FamilyName

u can select whatever u want, the most important thing is to pick one style during ur scripts not to get confused while using variables.

Creating Variables:

Unlike many different programming languages u don’t need need to create a variable before using it, it won’t case a fatal error nor case the compile to be stopped, in PHP u can use the variable and PHP will create it 4 u. so -> storing information in a variable creates i.

Important notes:

1. To create a variable write $ variable_name; (Creating it without storing any information in it)

or directly assign ur variable a value

$ number = 123; (initialize a value for ur variable)

2. To store information in a variable use the single equal sign (=)

3. The quotes tell PHP that u r storing a String which handled by PHP as a unit

4. If u put information in a variable that doesn’t previously exist, you will create this variable.

5. u can store a values in one variable into another variable

Example: $first_name = “Noor”;

$first_name_updated = “Neno”;

$first_name = $first_name_updated ;

This will case the value in the variable first_name to be “Neno” and the $first_name_updated variable will still has its information “Neno” but if we write it vise verse

$first_name_updated = $first_name ;

then both $first_name and $first_name_updated variables will have the string value “Noor”.

Links in HTML (Methods of Links) August 26, 2008

Posted by Nsh15 in HTML.
Tags: , , , , , , ,
add a comment

There are different ways to provide these links. The three most common ones are:

  • clicking on a word, phrase or sentence
  • clicking on an image (that is, a picture or graphic)
  • clicking on a button

1. clicking on a word, phrase or sentence:

it’s the simplest way, u add the sentence u want it to be click able between the a href tag

<a href= “URL”> ur sentence </a>

2. clicking on an image (that is, a picture or graphic):

u add the img code instead of code between the a href tag.

U can check this post about images Images in HTML.

Examples:

i want to make some images that links u to my blog homepage

<a href=”http://me2learn.wordpress.com“><img src=”http://dl4.glitter-graphics.net/pub/694/694714pn317stslu.gif” border=”0” alt=”" width=”128” height=”128” /></a>

<a href=”http://me2learn.wordpress.com“><img src=”http://dl5.glitter-graphics.net/pub/482/482595bp20ksiiv6.gif” border=”0” alt=”" width=”115” height=”115” /></a>

<a href=”http://me2learn.wordpress.com“><img src=”http://dl7.glitter-graphics.net/pub/427/427837dh1uo378hf.gif” border=”0” alt=”" width=”110” height=”110” /></a>

And my links will looks like:

3. clicking on a button:

Buttons are neat and professional looking.

<H3 ALIGN=”CENTER“>
<FORM METHOD=”GET” ACTION=”URL“>
<INPUT TYPE=”submit” VALUE=”Return to Home Page“>
</FORM></H3>

There are two main command lines here. The first one is called the FORM command and the second one is called the INPUT command. FORM is a container element. The opening tag tells the browser that a form item is going here. The closing tag </FORM> ends the form item (which you see at the end of the statements).

* The FORM command has two attributes : METHOD and ACTION.

METHOD, a FORM attribute, tells the browser how to handle the FORM command. Its value here is “GET”. That is, the browser is to “get” something which in this case points to a link through the ACTION attribute

ACTION means the connection that you want to make, be sure to type in the complete address (URL). ACTION is a required attribute as it specifies the URL of the location you want to link to.

* The INPUT command which generates the button

The TYPE attribute lets the browser know what TYPE of INPUT will occur. In this case we want to SUBMIT a button (a button is assumed in “submit”). Thus TYPE=”submit” produces a button.

The VALUE attribute gives the wording that will appear on the button.

Example:

create a button link to my blog home page

<H4 ALIGN=”CENTER“>
<FORM METHOD=”GET” ACTION=”http://me2learn.wordpress.com“>
<INPUT TYPE=”submit” VALUE=”My blog home page“>
</FORM></H4>

p.s… buttons can’t be saved in wordpress, so try it in a notepad and see how it will appear

Links in HTML (Types of Links) August 26, 2008

Posted by Nsh15 in HTML.
Tags: , , , , , , , , , ,
7 comments


Links are used to “link” a visitor from one area to another.There area many types of links :

  • Local: A page on the same server or directory
  • Internal: A section on the current page or document
  • External: A page or site on a different server or directory
  • Download: A file for the visitor to download
  • E-mail: Opens the visitor’s e-mail program

1. Local Links:

A Local link uses a page name (including sub-directories if needed) as the target. It is “local” to the current server.

<a href=”Page_in_the_same_server.html“>
Click here to go to the local page
</a>

2.Internal Links:

Internal links can also be called page jump, u can make this jump with two simple steps

First step:

assign the place of the page where u want the pointer to move, and bookmark it by adding this cod in it

<A NAME=”ur bookmark name“></A>

u will need the “ur bookmark name” in the next step.

Second step:

u need to add a link in anyplace in ur page to let the user move to ur bookmark point from it

<A HREF=”#ur bookmark name “> Add the text to be displayed and clicked by the user </A></P>

The A stands for Anchor. In general, the anchor tag tells the browser to anchor or to attach to something else. Every Anchor tag must have a closing or end tag (</A>) to signal the end of the anchor. HREF stands for Hypertext REFerence. It means that “this is where the link is going to.

Example:

lets add a link to move the user to the top of the current page

first step: we add the bookmark code at the top of the page

<A NAME=”top“></A>

second step: add the link anywhere in ur page

<A HREF=”#top “> click here to go to the top of this page </A></P>

and this is my link:
click here to go to the top of this page

the link will take u few lines above since we are not far from the top of this page


3. External Links:

To link to any page in the world,u need the (URL) of the page you want to link to.

<a href = “URL for the website“> text to click on </a>

Example:

i want to link to my blog home page, so i will use this code

<a href = “http”//me2learn.wordpress.com“> Click here to visit my blog, enjoy! </a>

and this is my link

Click here to visit my blog, enjoy!

4. Download links:

File links are used for allowing a visitor to download a file. These links are set up exactly the same as the local or external links. Instead of “pointing” to another page or site, it points to a file. When the user clicks on this link, the browser knows it is a file and will ask the visitor if they want to download the file. The types of files available to be used for download depends on your online server. A common and most accepted type is a ZIP file.

<a href=”File URL.zip“>
Click here to d ownload this file
</a>

u can get the file URL by uploading ur file to any uploading site and they will give u the URL for ur file.

5. E-mail links:

The e-mail link is for receiving e-mail and feedback from visitors. This link will prompt the browser’s e-mail program to start and place the e-mail address in automatically.

<a href= “mailto: mail_address@mail.com“>

click here ti send me e-mail </a>

Note the mailto: in the HREF value. This is how the browser detects an e-mail setting instead of a web page setting.

* You can also add set the subject, cc and bcc lines as part of the mailto:

The subject line of an e-mail can be filled in automatically by adding a SUBJECT property:

<a href = “mailto: mail_address@mail.com?subject = ‘e-mail from the web-site’“>

click here ti send me e-mail </a>

the cc and bcc can be added in the same way replacing their name instead of the subject word.

Link colors:

Links, by default, show up in different colors from the rest of the text on your web page. These settings are found in the individual browser settings. To over-ride these settings, you can declare your own link colors in the opening BODY tag:

  • LINK: Color of an non-activated link. (default blue)
  • VLINK: Color of a previously visited link. (default red)
  • ALINK: Color of a currently active link. (default orange)

<body link= “#0000ff“  vlink= “#ff0000” alink= “#ff8429“  > ur HTML code here </body>

Using the hex color codes, you can choose the colors to suit your page. The ALINK is not used much. There aren’t many instances when there is an open link at the same time as the current page. Be sure you are just inserting these properties into the current opening BODY tag.Do NOT create a second opening BODY tag. Any given HTML document can have only one BODY tag set. Any more than one set will result with page errors.

Align objects in your page August 25, 2008

Posted by Nsh15 in HTML.
Tags: , , , ,
add a comment

Align is actually a property of a tag. It is not a tag itself. It can be used in many different tags. The most common is the Paragraph tag. Align moves text or other objects on the web page to the: left , right or center

Remember that left align is the default

Examples:

<p align= “center“> This Paragraph <br> centered in the middle of the page <br>

<img src = “http://i85.photobucket.com/albums/k58/nitr2/msicons3/seashells-100×100.jpg” align = “center“></p> <br><br>

<p align = “right“> This Paragraph <br> locates at the right side of the page <br>

<img src = “http://i85.photobucket.com/albums/k58/nitr2/msicons3/wave-100×100.jpg” align = “right“> </p> <br><br>

<p align = “left“> This Paragraph <br> locates at the left “default” side of the page <br>

<img src = “http://i85.photobucket.com/albums/k58/nitr2/msicons3/lightning-strike-100×100.jpg“> </p>

the above three paragraphs may looks like:

This Paragraph
centered in the middle of the page

This Paragraph
locates at the right side of the page

This Paragraph
locates at the left “default” side of the page

Create HTML Lists August 25, 2008

Posted by Nsh15 in HTML.
Tags: , , , , ,
add a comment

basically there are three types of list in HTML, unordered, Ordered and definition lists:

1. Unordered lists:

This list type has a start character of a dot or other ‘bullet’ style character. To create each line and start character, the <li> or LINE tag set is used. There is no need to use a <BR> or <P> tag to skip to the next line. it does it automatically.

<ul>
<li> First line</li>
<li> Second line </li>
<li> third line </li>
</ul>

The symbols before the items are a default DISC(dot). Using the TYPE property, you can choose a value of CIRCLE or SQUARE for a different look. Its important to enter the value for UL in lowercase

<ul type = “square>
<li> First line</li>
<li> Second line </li>
<li> third line </li>
</ul>

Example:

the above codes will give us the following two lists:

  • First line
  • Second line
  • third line
  • First line
  • Second line
  • third line

2. Ordered lists:

This list type produces numerical characters on each line instead of a bullet characters.<ol> is for ordered list. The list now has numbers instead of a ‘bullet’ before the list items.

The numbers before the items are a default called 1. Using the TYPE property, you can choose a value of a, A, i, or I for a different look.

<ol>
<li> First line</li>
<li> Second line </li>
<li> third line </li>

</ol>

or with specifying the type:

<ol type = “I”>
<li> First line</li>
<li> Second line </li>
<li> third line </li>

</ol>

Example :

the above codes will give us the following lists

  1. First line
  2. Second line
  3. third line
  1. First line
  2. Second line
  3. third line

3. Definition lists:

This list type is a little different. It creates a TITLE line and a DATA area.

DL Definition List tags.
DT Definition Title.
DD Definition Data.

Example:

<dl>
<dt> First Line
<dd> First line means that the first line u c in any page … it can be a header or a title
<dt> Second line
<dd> its hard to define it but it can be the line below the first line lol!
</dl>

it will looks like:

First Line
First line means that the first line u c in any page … it can be a header or a title
Second line
its hard to define it but it can be the line below the first line lol!

Nested Lists:

These will create a list, inside another list. Each new list will be indented from the one before. This will work for BOTH Unordered lists and Ordered lists.Using a nested list makes it possible to create sub-catagories from a main list. Take note that a full set of list tags are used to nest a list and the nested (sub) list tags are NOT overlapping the main list tags. Anything beyond 3 nests gets confusing and usually makes a web page look cluttered, so don’t over do it.

Example:

<ul>
<li> First line </li>
<ul>
<li> first line-1 </li>
<li>
first line-2 </li>
</ul>
<li> second line </li>
<li> third line </li>
</ul>

our nested list will looks like:

  • First line
    • first line-1
    • first line-2
  • second line
  • third line
Follow

Get every new post delivered to your Inbox.