Thursday, 31 May 2012

Sql Database queries


The SELECT ... FROM Clause
The most basic SELECT statement has only 2 parts: (1) what columns you want to return and (2) what table(s) those columns come from.
If we want to retrieve all of the information about all of the customers in the Employees table, we could use the asterisk (*) as a shortcut for all of the columns, and our query looks like
SELECT * FROM Employees

If we want only specific columns (as is usually the case), we can/should explicitly specify them in a comma-separated list, as in
SELECT EmployeeID, FirstName, LastName, HireDate, City FROM Employees

which results in the specified fields of data for all of the rows in the table:

Explicitly specifying the desired fields also allows us to control the order in which the fields are returned, so that if we wanted the last name to appear before the first name, we could write
SELECT EmployeeID, LastName, FirstName, HireDate, City FROM Employees

Friday, 6 January 2012

HTML - Upload Forms


Use an upload form to allow users to upload pictures, movies, or even their own webpages. An upload form is another type of input form, simply set the type attribute to file.

 

HTML Code:

<input type="file" />

Upload Form:



Max File Size

To limit the size of the file being uploaded and saving you precious webserver space. We make use of a hidden input field and set a few specific attributes.

HTML Code:

<input type="hidden" name="MAX_FILE_SIZE" value="500" />
< input type="file" />

Max File Size:


The value specified is the maximum allowable KB to be uploaded via this form. A value of 100 will allow a file up to 100kb.

Javasript Codes For Putting Current Date On Your Website

The Date object is useful when you want to display a date or use a timestamp in some sort of calculation. In Java, you can either make a Date object by supplying the date of your choice, or you can let JavaScript create a Date object based on your visitor's system clock. It is usually best to let JavaScript simply use the system clock.
When creating a Date object based on the computer's (not web server's!) internal clock, it is important to note that if someone's clock is off by a few hours or they are in a different time zone, then the Date object will create a different times from the one created on your own computer.

JavaScript Date Today (Current)

To warm up our JavaScript Date object skills, let's do something easy. If you do not supply any arguments to the Date constructor (this makes the Date object) then it will create a Date object based on the visitor's internal clock.

HTML & JavaScript Code:

<h4>It is now  
<script type="text/javascript">
<!--
var currentTime = new Date()
//-->
</script>
</h4>

Display:

It is now

Nothing shows up! That's because we still don't know the methods of the Date object that let us get the information we need (i.e. Day, Month, Hour, etc).

Get the JavaScript Time

The Date object has been created, and now we have a variable that holds the current date! To get the information we need to print out, we have to utilize some or all of the following functions:
  • getTime() - Number of milliseconds since 1/1/1970 @ 12:00 AM
  • getSeconds() - Number of seconds (0-59)
  • getMinutes() - Number of minutes (0-59)
  • getHours() - Number of hours (0-23)
  • getDay() - Day of the week(0-6). 0 = Sunday, ... , 6 = Saturday
  • getDate() - Day of the month (0-31)
  • getMonth() - Number of month (0-11)
  • getFullYear() - The four digit year (1970-9999)
Now we can print out the date information. We will be using the getDate, getMonth, and getFullYear methods in this example.

HTML & JavaScript Code:

<h4>It is now  
<script type="text/javascript">
<!--
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
//-->
</script>
</h4>

Display:

It is now 1/7/2012 !

Notice that we added 1 to the month variable to correct the problem with January being 0 and December being 11. After adding 1, January will be 1, and December will be 12.