Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

ASSIGNMENT

Advanced Web Technology

Question.1 Explain Installing process of MySQL on Windows?


Answers:- To download MySQL installer, go to http://dev.mysql.com/downloads/installer/
Install MySQL via MySQL Installer
To install MySQL using the MySQL installer, double-click on the MySQL installer file and
follow the steps below:
Step 1: Windows configures MySQL Installer.
Step 2 – Welcome Screen: A welcome screen provides several options. Choose the first option:
Install MySQL Products.
Step 3 – Download the latest MySQL products: MySQL installer checks and downloads the
latest MySQL products including MySQL server, MySQL Workbench, etc.
Step 4: Click the Next button to continue.
Step 5 – Choosing a Setup Type: there are several setup types available. Choose the Full option
to install all MySQL products and features.
Step 6 – Checking Requirements.
Step 7 – Installation Progress: MySQL Installer downloads all selected products. It will take a
while, depending on which products you selected and the speed of your internet connection.
 downloading Products in progress.
 Complete Downloading. Click the Next button to continue…
Step 8 – Configuration Overview. Click the Next button to configure MySQL Database Server.
 Configuration: choose Config Type and MySQL port (3006 by default) and click Next
button to continue.
 Configuration: choose a password for the root account. Please note the password
download and keep it securely if you are installing MySQL database server on a
production server. If you want to add a more MySQL user, you can do it in this step.
 Configuration: choose Windows service details including Windows Service Name and
account type, then click Next button to continue.
 Configuration – In Progress: MySQL Installer is configuring MySQL database server.
Wait until it is done and click the Next button to continue.
 Configuration – Done. Click the Next button to continue.
Step 9 – Installation Completes: the installation completes. Click the Finish button to close the
installation wizard and launch the MySQL Workbench.

1
Question.2 Write a program to Connect Database already created in MySQL.
Program:-

<?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

Question.3 Write a PHP script to showing Function call.


Program:-

<?php
function writeMsg() {
echo "Hello world!";
}

writeMsg(); // call the function


?>

2
Question.4 Explain various MySQL Data Types?
Answers:- MySQL Data Types are of three types they are:-

 Numeric Data Type

Data Type Description


Syntax

INT  A normal-sized integer that can be signed or unsigned.


 signed, range is from -2147483648 to 2147483647.
 unsigned, the allowable range is from 0 to 4294967295.
 You can specify a width of up to 11 digits.

TINYINT  A very small integer that can be signed or unsigned.


 signed, the allowable range is from -128 to 127.
 unsigned, the allowable range is from 0 to 255.
 You can specify a width of up to 4 digits.

SMALLINT  A small integer that can be signed or unsigned.


 signed, the allowable range is from -32768 to 32767.
 unsigned, the allowable range is from 0 to 65535.
 You can specify a width of up to 5 digits.

MEDIUMINT  A medium-sized integer that can be signed or unsigned.


 signed, the allowable range is from -8388608 to 8388607.
 unsigned, the allowable range is from 0 to 16777215.
 You can specify a width of up to 9 digits.

BIGINT  A large integer that can be signed or unsigned.


 signed, the allowable range is from -9223372036854775808 to
9223372036854775807.
 unsigned, the allowable range is from 0 to 18446744073709551615.
 You can specify a width of up to 20 digits.

3
 Date and Time Data Type:

Data Type Maximum Size Explanation


Syntax

DATE Values range from '1000-01-01' to '9999-12- Displayed as 'yyyy-mm-dd'.


31'.

DATETIME Values range from '1000-01-01 00:00:00' to Displayed as 'yyyy-mm-dd


'9999-12-31 23:59:59'. hh:mm:ss'.

TIMESTAMP(m) Values range from '1970-01-01 00:00:01' Displayed as 'YYYY-MM-


UTC to '2038-01-19 03:14:07' TC. DD HH:MM:SS'.

TIME Values range from '-838:59:59' to Displayed as 'HH:MM:SS'.


'838:59:59'.

YEAR[(2|4)] Year value as 2 digits or 4 digits. Default is 4 digits.

 Large Object Data Types (LOB) Data Types:

Data Type Syntax Maximum Size

TINYBLOB Maximum size of 255 bytes.

BLOB(size) Maximum size of 65,535 bytes.

MEDIUMBLOB Maximum size of 16,777,215 bytes.

LONGTEXT Maximum size of 4gb or 4,294,967,295 characters.

4
Question.5 Write Short Note on following. (any 4)
Answers:-
 Static webpages and Dynamic webpages
Static Web pages:
Static Web pages are very simple. It is written in languages such as HTML, JavaScript, CSS, etc.
For static web pages when a server receives a request for a web page, then the server sends the
response to the client without doing any additional process. And these web pages are seen
through a web browser. In static web pages, Pages will remain the same until someone changes it
manually.
Dynamic Web Pages:
Dynamic Web Pages are written in languages such as CGI, AJAX, ASP, ASP.NET, etc. In
dynamic web pages, the Content of pages is different for different visitors. It takes more time to
load than the static web page. Dynamic web pages are used where the information is changed
frequently, for example, stock prices, weather information, etc.
Difference between Static and Dynamic Web Pages:
S.No Static Web Pages Dynamic Web Pages

In static web pages, Pages will In dynamic web pages, Content of


remain same until someone pages are different for different
1. changes it manually. visitors.

Static Web Pages are simple in


2. terms of complexity. Dynamic web pages are complicated.

In static web pages, Information In dynamic web page, Information are


3. are change rarely. change frequently.

Static Web Page takes less time for Dynamic web page takes more time
4. loading than dynamic web page. for loading.

In Static Web Pages, database is In dynamic web pages, database is


5. not used. used.

Static web pages are written in Dynamic web pages are written in
languages such as: HTML, languages such as: CGI, AJAX, ASP,
6. JavaScript, CSS, etc. ASP.NET, etc.

5
 CSS
CSS stands for Cascading Style Sheets. It is a style sheet language which is used to describe the
look and formatting of a document written in markup language. It provides an additional feature
to HTML. It is generally used with HTML to change the style of web pages and user interfaces.
It can also be used with any kind of XML documents including plain XML, SVG and XUL.
CSS is used along with HTML and JavaScript in most websites to create user interfaces for web
applications and user interfaces for many mobile applications.
These are the three major benefits of CSS:
 Solves a big problem
 Saves a lot of time
 Provide more attributes
CSS Syntax as follows −

selector { property: value }

 Selector − A selector is an HTML tag at which a style will be applied. This could be any
tag like <h1> or <table> etc.
 Property − A property is a type of attribute of HTML tag. Put simply, all the HTML
attributes are converted into CSS properties. They could be color, border etc.
 Value − Values are assigned to properties. For example, color property can have value
either red or #F1F1F1 etc.

<!DOCTYPE html>
<html>
<head>
<style>
p{
color: red;
text-align: center;
}
</style>
</head>
<body>

<p>Hello World!</p>
<p>These paragraphs are styled with CSS.</p>

</body>
</html>

6
 Loops:-
When you write code, you want the same block of code to run over and over again a certain
number of times. So, instead of adding several almost equal code-lines in a script, we can use
loops.
Loops are used to execute the same block of code again and again, as long as a certain condition
is true.
In PHP, we have the following loop types:
 while - loops through a block of code as long as the specified condition is true
 do...while - loops through a block of code once, and then repeats the loop as long as the
specified condition is true
 for - loops through a block of code a specified number of times
 foreach - loops through a block of code for each element in an array
While Loop
The while loop executes a block of code as long as the specified condition is true.
Syntax

while (condition is true) {


code to be executed;
}

Examples

<?php
$x = 1;

while($x <= 5) {
echo "The number is: $x <br>";
$x++;
}
?>

Do...while Loop
The do...while loop will always execute the block of code once, it will then check the condition,
and repeat the loop while the specified condition is true.

7
Examples

<?php
$x = 1;

do {
echo "The number is: $x <br>";
$x++;
} while ($x <= 5);
?>

For Loop
The For loop is used when you know in advance how many times the script should run.
Syntax

for (init counter; test counter; increment counter) {


code to be executed for each iteration;
}

Examples

<?php
for ($x = 0; $x <= 10; $x++) {
echo "The number is: $x <br>";
}
?>

 Form in PHP

<html>
<body>

<form action="welcome.php" method="post">


Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>

8
Question.6 Different Between MySQL and MySQLi.
Answers:-

MySQL MySQLi

MySQL extension added in PHP version 2.0. MySQLi extension added in PHP 5.5 and
and deprecated as of PHP 5.5.0. will work on MySQL 4.1.3 or above.

Does not support prepared statements. MySQLi supports prepared statements.

MySQL provides the procedural interface. MySQLi provides both procedural and
object-oriented interface.

MySQL extension does not support stored MySQLi supports store procedure.
procedure.

MySQL extension lags in security and other MySQLi extension is with enhanced
special features, comparatively. security and improved debugging.

Transactions are handled by SQL queries only. MySQLi supports transactions through API.

Extension directory: ext/mysql. Extension directory: ext/mysqli.

9
Question.7 Write a PHP Program which create a login page by using POST method.
Program:-

<html>
<head>
<title>My First PHP Program!</title>
</head>

<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<p>username <input type="text" name="usser"/></p>
<p>password <input type="password" name="pass" /></p>
<p> <input type="submit" name="submit" /></p>
</form>
<?php
$name = $_REQUEST['usser'];
$pas=$_REQUEST['pass'];
if($name=="mandeep"&&$pas=="mani"){
echo "successful";
}
else{
echo "Login Failed";
}
?>
</body>
</html>

Question.8 What is String? How we Manipulating string in PHP?


Answers:- A string is a sequence of letters, numbers, special characters and arithmetic values or
combination of all. The simplest way to create a string is to enclose the string literal (i.e. string
characters) in single quotation marks ('), like this:

$my_string = 'Hello World';

There are 4 ways to specify a string literal in PHP.


1. single quoted
2. double quoted
3. heredoc syntax
4. newdoc syntax (since PHP 5.3)

10
Manipulating String:-
 strlen() - Return the Length of a String. The PHP strlen() function returns the length of a
string.
Example
Return the length of the string "Hello world!":

<?php
echo strlen("Hello world!"); // outputs 12
?>

 str_word_count() - Count Words in a String. The PHP str_word_count() function counts


the number of words in a string.
Example
Count the number of word in the string "Hello world!":

<?php
echo str_word_count("Hello world!"); // outputs 2
?>

 strrev() - Reverse a String. The PHP strrev() function reverses a string.


Example
Reverse the string "Hello world!":

<?php
echo strrev("Hello world!"); // outputs !dlrow olleH
?>

11
Question.9 Explain following MySQL command.
Answers:-
SELECT Statement
 The SELECT statement is used to select data from a database.
 The data returned is stored in a result table, called the result-set.
 SELECT Syntax

SELECT column1, column2, ...


FROM table_name;

Here, column1, column2, ... are the field names of the table you want to select data from. If you
want to select all the fields available in the table, use the following syntax:

SELECT * FROM table_name;

WHERE Statement
We have seen the SQL SELECT command to fetch data from a MySQL table. We can use a
conditional clause called the WHERE Clause to filter out the results. Using this WHERE
clause, we can specify a selection criteria to select the required records from a table.
Syntax
The following code block has a generic SQL syntax of the SELECT command with the WHERE
clause to fetch data from the MySQL table −

SELECT field1, field2,...fieldN table_name1, table_name2...


[WHERE condition1 [AND [OR]] condition2.....

INSERT Statement
To insert data into a MySQL table, you would need to use the SQL INSERT INTO command.
You can insert data into the MySQL table by using the mysql> prompt or by using any script like
PHP.
Syntax
Here is a generic SQL syntax of INSERT INTO command to insert data into the MySQL table −

INSERT INTO table_name ( field1, field2,...fieldN )


VALUES ( value1, value2,...valueN );

12
To insert string data types, it is required to keep all the values into double or single quotes. For
example "value".

DELETE Statement
If you want to delete a record from any MySQL table, then you can use the SQL
command DELETE FROM. You can use this command at the mysql> prompt as well as in any
script like PHP.
Syntax
The following code block has a generic SQL syntax of the DELETE command to delete data
from a MySQL table.

DELETE FROM table_name [WHERE Clause]

 If the WHERE clause is not specified, then all the records will be deleted from the given
MySQL table.
 You can specify any condition using the WHERE clause.
 You can delete records in a single table at a time.
The WHERE clause is very useful when you want to delete selected rows in a table.

Submitted To:- Submitted From:-


Prof. Leena Joshi. Anshul Khapre
MIST Indore. 17159C04003
3rd Year 6th Sem

13

You might also like