08 Dec 2013
Popups in javascript
There are three kinds of popup boxes in JavaScript Who to define array in php? Alert box Alert box display message with ok button Example: <html> <script> alert(“Hello Viewers”); </script> </html> Confirm box Confirm box display message with ok and cancel button, it is use to take user confirmation. If we click ok, it returns […]
07 Dec 2013
Ways of Adding JavaScript code
Following are the ways to add JavaScript in html page. Inline : JavaScript code that we writes inside html tags are called inline JavaScript, useful to write short code in JavaScript. Example: <html> <body> <input type=”button” onclick=”alert(‘hello’)” value=”Hello”/> <input type=”button” value=”Delete” onclick=”return confirm(‘Sure To Delete’)”/> </body> </html> Internal : JavaScript written in same html page […]
07 Dec 2013
Advantages of javaScript
Easy to learn : JavaScript has simple, easy to learn syntax that we can use with html. Runs on Client Side : JavaScript runs on client side, means it use our own system memory(RAM,etc.) to run, so it’s faster than the server side scripting language, that use server’s memory. Features of programming languages : JavaScript […]
07 Dec 2013
Get Last Inserted Id
There are many cases where we need AUTO_INCREMENT ID that generated from the previous INSERT operation, we can get that by using mysql_insert_id() function. Like:- $con = mysql_connect(“localhost”, “root”, “”); mysql_select_db(“my_database”,$con); $query = ”insert into emp (name,salary,phone) values (‘amit’,9000,’9847476744’)”; mysql_query($query); echo “Last inserted id is ”. mysql_insert_id(); Some time programmer use “select max(id) from tablename” […]
01 Dec 2013
Object Oriented PHP
The Major difference between PHP 4 and PHP 5 is, PHP 4 is not object oriented but PHP 5 is full object model. Some Features of Object Oriented Language:- Class: is a collection of member variables and functions. Object: is a instance of the class. We can define a class once and then make many […]
30 Nov 2013
Calculate Age out of Date Of Birth
Generally we store date of birth in our database and in front end we have to display age also. In php we can use following code to calculate AGE out of date of birth. $dateofbirth = “12/08/1984”; echo floor((time() – strtotime($dateofbirth))/31556926); Any question please write in comments.
30 Nov 2013
Change Date Format in php
How to change date format in php? we can display date in different formats in php as given:- $dt = “2001/02/02”; echo date(‘d M Y’, strtotime($dt)); Output:- 02 Feb 2001 $dt = “2001/02/02”; echo date(‘M d Y’, strtotime($dt)); Output:- Feb 02 2001
23 Nov 2013
Operators in SQL Server
Conditional Operators:- =, , =, , !=, !>, !< Example: Select * from emp where id=1 Select * from emp where salary > 9000 Logical Operators:- and, or, not, between, like, in, all, any, some Example: Select * from emp where salary>999 and city=”Chandigarh”; Note:- Both Condition should be satisfied. Select * from emp where […]
23 Nov 2013
File Upload in PHP
<html> <body> <form action=”upload.php” enctype=”multipart/form-data” method=”post”> <input type=”file” name=”myFile” id=”myFile”><br> <input type=”submit” name=”submit” value=”Submit”> </form> <body> </html> Create another file “upload.php” that contains the code to uploading a file: <?php if(move_uploaded_file($_FILES[“myFile”][“tmp_name”],$_FILES[“myFile”][“name”])) { echo $_FILES[“file”][“name”].”Saved”; } else { echo “Unable To Save”; } ?> Other Parameters:- $_FILES[“file”][“type”] – to get file type. $_FILES[“file”][“size”] – to get […]
19 Nov 2013
Submit Form without Submit Button
We can submit form on server with submit button by using Java script submit() function. like, if we want submit form on dropdown change, we can write a code:- <form> <select onchange=”this.form.submit()”> </form>