Internet and Web Application Development Revision.

19
Internet and Web Application Development Revision

Transcript of Internet and Web Application Development Revision.

Page 1: Internet and Web Application Development Revision.

Internet and Web Application Development

Revision

Page 2: Internet and Web Application Development Revision.

04/19/23 Web 2

Revision

1. What is the difference between Internet and The Word Wide Web ?

• Internet : a physical network connecting millions of computers using the same protocols for sharing/transmitting information (TCP/IP) in reality, the Internet is a network of smaller networks

• World Wide Web: a collection of interlinked multimedia documents that are stored on the Internet and accessed using a common protocol (HTTP)

2. Give 3 examples of Internet-based applications email, telnet, ftp, instant messaging services, file-sharing services

Page 3: Internet and Web Application Development Revision.

04/19/23 Web 3

Revision

3. Why do we use CSS in html?• HTML was never meant to be a presentation language. • CSS removes the presentation attributes from the structure allowing

reusability, ease of maintainability, and an interchangeable presentation layer.

• CSS allows us to make global and instantaneous changes easily.

4. Write a CSS code to change the body background-color, the color and text-align of the large bold heading (h1), the font-family and font-size of all paragraphs

Page 4: Internet and Web Application Development Revision.

04/19/23 Web 4

Revision

<html><head><style>body{background-color:#d0e4fe;}h1{color:orange;text-align:center;}p{font-family:"Times New Roman";font-size:20px;}</style></head>

<body>

<h1>CSS example!</h1><p>This is a paragraph.</p>

</body></html>

Page 5: Internet and Web Application Development Revision.

04/19/23 Web 5

Revision

5. What file extension should CSS files have? .css

6. Which tag is used to create paragraphs?< p >

7. Which attribute is used to set inline styles for tags?style

8. PHP server scripts are surrounded by delimiters, which?

<?php ?>

9. How do you write "Hello World" in PHPecho "Hello World";

Page 6: Internet and Web Application Development Revision.

04/19/23 Web 6

Revision

10. Where in an HTML document is the correct place to refer to an external style sheet?

In the <head> section

11. All variables in PHP start with which symbol?$

12. What is the correct way to end a PHP statement?;

13. How do you get information from a form that is submitted using the "get" method?

$_GET[];

Page 7: Internet and Web Application Development Revision.

04/19/23 Web 7

Revision

14. Which HTML tag is used to define an internal style sheet?<style>

15. Which CSS property controls the text size?font-size

16. Which property is used to change the font of an element?font-family

17. What is the correct way to create a function in PHP? function myFunction()

18.What is the correct way to connect to a MySQL server?mysql_connect(host,username,password);

19. What is the correct way to add 1 to the $count variable?$count++;

Page 8: Internet and Web Application Development Revision.

04/19/23 Web 8

Revision

15. Which SQL statement is used to extract data from a database?

SELECT

16. Which SQL statement is used to delete data from a database?

DELETE

17. Inside which HTML element do we put the JavaScript?<script>

18. Where is the correct place to insert a JavaScript?Both the <head> section and the <body> section are correct

19. What is the correct syntax for referring to an external script called "xxx.js"?

<script src="xxx.js">

Page 9: Internet and Web Application Development Revision.

04/19/23 Web 9

Revision

20. What is the difference between the Alert Box and the Confirm Box in javascript? An alert box is often used if you want to make sure information comes

through to the user. When an alert box pops up, the user will have to click "OK" to proceed. A confirm box is often used if you want the user to verify or accept

something. When a confirm box pops up, the user will have to click either "OK" or

"Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the

box returns false.

Page 10: Internet and Web Application Development Revision.

04/19/23 Web 10

Revision

21. What is the result of the following code?

<html> <head> <script>function myFunction(){var x="",i;for (i=0;i<5;i++) { x= "The number is " + i + "<br>"; document.write(x); }}</script></head><body><p>Click the button to loop through a block of code five times.</p><button onclick="myFunction()">Try it</button><p id="demo"></p></body> </html>

Page 11: Internet and Web Application Development Revision.

04/19/23 Web 11

Revision

When the user click on the button named “Try it” the following 5 lines will be displayed :

The number is 0The number is 1The number is 2The number is 3The number is 4

Page 12: Internet and Web Application Development Revision.

04/19/23 Web 12

Revision

22. Transform the for LOOP into While LOOP

<html><head><script>function myFunction(){var x="",i=0;while (i<5) { x= "The number is " + i + "<br>"; document.write(x); i++; }}</script></head>

Page 13: Internet and Web Application Development Revision.

04/19/23 Web 13

Revision

23. Give 3 javascript mouse events

onmouseover/onmouseout - When the mouse passes over an elementonmousedown/onmouseup - When pressing/releasing a mouse buttononmousedown - When mouse is clicked: Alert which element

24. What will display the next code?<html><body><p id="demo">Click the button to sort the array.</p>

<button onclick="myFunction()">Try it</button><script>function myFunction()

{var fruits = ["Banana", "Orange", "Apple", "Mango"];fruits.sort();var x=document.getElementById("demo");

x.innerHTML=fruits;}</script></body> </html>

Page 14: Internet and Web Application Development Revision.

04/19/23 Web 14

Revision

fruits.sort();var x=document.getElementById("demo");x.innerHTML=fruits;}</script></body> </html>This code sort the table fruits and when the user click on the button

“Try it”, the content of the table will be displayed in the screen.

Page 15: Internet and Web Application Development Revision.

04/19/23 Web 15

Revision

25. Write a javascript code to display the current date ad time

<html><body><script>var d=new Date();document.write(d);</script></body></html>

Page 16: Internet and Web Application Development Revision.

04/19/23 Web 16

Revision

26. What are the basic steps to Process Databases with PHP and MYSQL?1.Connect to host server which has Mysql installed2.Select a database 3.Form an SQL statement4.Execute the SQL statement and (optionally) return a record set5.Extract data from recordset using php6.Close connection

Page 17: Internet and Web Application Development Revision.

04/19/23 Web 17

Revision

27. Write a php code to connect to MYSQL and select the database named “university”.<?php$host = "127.0.0.1";$username = "root";$pswd = "";$dbName = "university";$con = mysql_connect($host, $username,$pswd);if (!$con){  die("Could not connect:" . mysql_error());}$db = @mysql_select_db($dbName,$con) or die(mysql_error());if ($db)echo" now you use the university datebase";?>

Page 18: Internet and Web Application Development Revision.

04/19/23 Web 18

Revision

28. Write a php code to create the table :Persons(FirstName varchar(15),LastName varchar(15), Age int ) <?php

$host = "127.0.0.1";

$username = "root";

$pswd = "";

$dbName = “university";

$con = mysql_connect($host, $username,$pswd);

if (!$con){  die("Could not connect:" .mysql_error());}

$db = @mysql_select_db($dbName,$con) or die(mysql_error());

$sql = "CREATE TABLE Persons(FirstName varchar(15),

LastName varchar(15),

Age int )";

mysql_query($sql, $con);

?>

Page 19: Internet and Web Application Development Revision.

04/19/23 Web 19

Revision29. Write a php code to insert the following records in the table Persons:(“Ibrahim”, “Moncef”, 40)(“Mohamed”, “Salah”, 30)<?php

$host = "127.0.0.1"; $username = "root"; $pswd = "";

$dbName = "mydb";

$con = mysql_connect($host, $username,$pswd);

if (!$con){  die("Could not connect:" . mysql_error());}

$db = @mysql_select_db($dbName,$con) or die(mysql_error());

mysql_query("INSERT INTO Persons VALUES (‘Ibrahim',‘Moncef',40)");

mysql_query("INSERT INTO Persons VALUES (‘Mohamed', ‘Salah', 30)");

mysql_close($con);

?>