Professional Documents
Culture Documents
wt on 14 exps
wt on 14 exps
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SlidesJS Example</title>
<meta name="description"
content="SlidesJS is a simple slideshow plugin for jQuery. ">
<!-- SlidesJS Required (if responsive):
Sets the page width to the device width. -->
<meta name="viewport"
content="width=device-width">
<!-- End SlidesJS Required -->
#slides .slidesjs-navigation {
margin-top: 3px;
}
#slides .slidesjs-previous {
margin-right: 5px;
float: left;
}
#slides .slidesjs-next {
margin-right: 5px;
float: left;
}
.slidesjs-pagination {
margin: 6px 0 0;
float: right;
list-style: none;
}
.slidesjs-pagination li {
float: left;
margin: 0 1px;
}
.slidesjs-pagination li a {
display: block;
width: 13px;
height: 0;
padding-top: 13px;
background-image: url(
https://media.geeksforgeeks.org/wp-content/uploads/20201213110552/logo.png);
background-position: 0 0;
float: left;
overflow: hidden;
}
.slidesjs-pagination li a.active,
.slidesjs-pagination li a:hover.active {
background-position: 0 -13px
}
.slidesjs-pagination li a:hover {
background-position: 0 -26px
}
#slides a:link,
#slides a:visited {
color: #333
}
#slides a:hover,
#slides a:active {
color: #9e2020
}
.navbar {
overflow: hidden
}
</style>
<body>
<!-- SlidesJS Required: Initialize SlidesJS with a jQuery doc ready -->
<script>
$(function() {
$('#slides').slidesjs({
width: 940,
height: 528,
navigation: false
});
});
</script>
<!-- End SlidesJS Required -->
</body>
</html>
Output:
AngularJS Directives
AngularJS directives are extended HTML attributes with the prefix ng-.
The ng-app directive initializes an AngularJS application.
The ng-init directive initializes application data.
The ng-model directive binds the value of HTML controls (input, select, textarea)
to application data.
Ng-app directives:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="" ng-init="firstName='John'">
<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="firstName"></p>
<p>You wrote: {{ firstName }}</p>
</div>
</body>
</html>
Output:
Name:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div data-ng-app="" data-ng-init="quantity=1;price=5">
<h2>Cost Calculator</h2>
Quantity: <input type="number" ng-model="quantity">
Price: <input type="number" ng-model="price">
<p><b>Total in dollar:</b> {{quantity * price}}</p>
</div>
</body>
</html>
Output:
Cost Calculator
Quantity: Price:
Total in dollar: 5
Ng-model:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body ng-app="myApp">
<w3-test-directive></w3-test-directive>
<script>
var app = angular.module("myApp", []);
app.directive("w3TestDirective", function() {
return {
template : "<h1>Made by a directive!</h1>"
};
});
</script>
</body>
</html>
Output:-
Made by a directive!
Apache webserver
Install MySQL
After downloading, unzip it, and double click the MSI installer .exe file.
1. "Choosing a Setup Type" screen: Choose "Full" setup type. This installs all
MySQL products and features. Then click the "Next" button to continue.
6. "Accounts and Roles" screen: Set a password for the root account. Click
"Next".
10. In the next screen, you can choose to configure the Router. Click on "Next",
"Finish" and then click the "Next" button.
11. "Connect To Server" screen: Type in the root password (from step 6).
Click the "Check" button to check if the connection is successful or not. Click on
the "Next" button.
12. "Apply Configuration" screen: Select the options and click the "Execute"
button. After finishing, click the "Finish" button.
httpd -k install
command to install the Apache2.4 service.
Step 4: After installing the service, you need to start the service. You
can manage it from the windows service program. You need to
open the “RUN” box using “Windows + R” key where you can
type “services.msc” command to open the Service” program. Open
the program and search Apache.
After that click on the “start” then Apache service is started. You can
stop or restart the service in the same place.
Step 5: Time to test the Apache. Open the browser and hit the
localhost in the URL.
Setup PHP
Please download the latest PHP version from the official site. Then
extract the downloaded zip folder as per your desired location. I
recommend this to store PHP folder in the same location where you
had setup the Apache Server. Now follow the given instruction to
install the PHP and setup this with the Apache server.
Step 3: Update the “httpd.conf” config file once again. Open the file
and append the following snippet.
PHPIniDir "F:/localserver/PHP-7.3.0"
Step 4: Restart the “Apache2.4” service. After that create one testing
PHP file under htdocs directory located
at “{directory_path}/Apache24/”. Here I have
created “phpinfo.php” page. At the end here the working PHP
setup.
Setup MySQL Server
You need to download the latest version of MySQL Server from the
official site. I’m choosing an installer setup for my windows 10. After
download completion, you need to follow the steps given below:
You can download the phpMyAdmin from the official site. Extract the
downloaded zip file in “{directory_path}/Apache24/htdocs” and
rename the folder to “phpmyadmin”.
DirectoryIndex index.php
</IfModule>
/**
*/
/* Authentication type */
$cfg['Servers'][$i]['password'] = 'password'; //mysql password here. here you need to add the
password which you setup at the time of mysql server authentication setup.
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in single variables could look
like this:
$cars1 = "Volvo";
$cars2 = "BMW";
$cars3 = "Toyota";
However, what if you want to loop through the cars and find a specific one? And what if you had not 3
cars, but 300?
The solution is to create an array!
An array can hold many values under a single name, and you can access the values by referring to an
index number.
Types of arrays :-
1.php index array
2.php associative array
3.php multidimensional array
<!DOCTYPE html>
<html>
<body>
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
</body>
</html>
Output:-
I like Volvo, BMW and Toyota.
Code:
<!DOCTYPE html>
<html>
<body>
<?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "Peter is " . $age['Peter'] . " years old.";
?>
</body>
</html>
Output:-
Peter is 35 years old.
php multidimensional array
A multidimensional array is an array containing one or more arrays.
PHP supports multidimensional arrays that are two, three, four, five, or more levels deep. However,
arrays more than three levels deep are hard to manage for most people.
The dimension of an array indicates the number of indices you need to select an element.
For a two-dimensional array you need two indices to select an element
For a three-dimensional array you need three indices to select an element
Code:-
<!DOCTYPE html>
<html>
<body>
<?php
$cars = array (
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
To show the values in the input fields after the user hits the submit button, we add a little PHP
script inside the value attribute of the following input fields: name, email, and website. In the comment
textarea field, we put the script between the <textarea> and </textarea> tags. The little script outputs
the value of the $name, $email, $website, and $comment variables.
Then, we also need to show which radio button that was checked. For this, we must manipulate the
checked attribute (not the value attribute for radio buttons)
Code:
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
// check if URL address syntax is valid (this regular expression also
allows dashes in the URL)
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-
9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
$websiteErr = "Invalid URL";
}
}
if (empty($_POST["comment"])) {
$comment = "";
} else {
$comment = test_input($_POST["comment"]);
}
if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = test_input($_POST["gender"]);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
Output:
E-mail: *
Website:
Comment:
Submit
Your Input:
19.write php program to perform various operations on a database table using functions?
1. <?php
2. $host = 'localhost:3306';
3. $user = '';
4. $pass = '';
5. $conn = mysqli_connect($host, $user, $pass);
6. if(! $conn )
7. {
8. die('Could not connect: ' . mysqli_connect_error());
9. }
10. echo 'Connected successfully<br/>';
11.
12. $sql = 'CREATE Database mydb';
13. if(mysqli_query( $conn,$sql)){
14. echo "Database mydb created successfully.";
15. }else{
16. echo "Sorry, database creation failed ".mysqli_error($conn);
17. }
18. mysqli_close($conn);
19. ?>
Output:
Connected successfully
Database
PHP cookie is a small piece of information which is stored at client browser. It is used to
recognize the user.
Cookie is created at server side and saved to client browser. Each time when client sends
request to the server, cookie is embedded with request. Such way, cookie can be received
at the server side.
Code:
1. <?php
2. setcookie("user", "Sonoo");
3. ?>
4. <html>
5. <body>
6. <?php
7. if(!isset($_COOKIE["user"])) {
8. echo "Sorry, cookie is not found!";
9. } else {
10. echo "<br/>Cookie Value: " . $_COOKIE["user"];
11. }
12. ?>
13. </body>
14. </html>
Ouput: