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 […]
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 […]
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” […]
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 […]
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.
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
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 […]
<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 […]
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>
By-default “Form 7” response message comes in the bottom of form, we can change its location, like in blow image i have written “[response]” at the top of my contact form, it will display the message at the top of the form.