Web Development Record Algorithms

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

PROGRAM-1:

1. Set up HTML structure with <!DOCTYPE html>, <html>, <head>, and <body> tags.
2. Set document title in the <title> tag inside the <head> section.
3. Use <marquee> tags in the <body> section to create scrolling text effects.
4. Specify attributes (if any) within <marquee> tags to control scrolling speed and direction.
5. Write the text content to be scrolled inside each <marquee> tag.
6. Browser renders the document, applying the specified scrolling effects to the text content.
Program-2:
1. 1.The HTML code consists of <html>, <head>, and <body> tags.
2. 2 Inside the <head> tag, there's a <title> tag setting the title of the document.
3. The <body> tag contains a <table> element representing the timetable.
4. Within the <table> element, there are several <tr> (table row) elements, each
representing a row in the timetable.
5. Inside each <tr> element, there are <th> (table header) elements for the column headers
and <td> (table data) elements for the cells containing subject names.
6. The first row (<tr>) contains column headers denoting the hours of the day.
7. The subsequent rows represent each hour of the day, with cells indicating the subjects
scheduled for that hour.
8. colspan attribute is used to merge cells across multiple columns when necessary.
9. The content within the cells represents the subjects or activities scheduled for each
hour/day of the week.
10. Subjects such as LIB (Library), CLOUD, OE (Open elective), SBS, DA (Data Analysis),
WEB LAB (Web Programming Lab), TRACK (Track Elective), R LAB (Research Lab),
and PROJECT LAB (Project Lab) are scheduled according to the provided timetable.

Program-3:

1. Create an HTML document with <html>, <head>, and <body> tags.


2. Set the title of the document using the <title> tag within the <head> section.
3. Create a heading (<h1>) with centered alignment to emphasize its importance.
4. Create an unordered list (<ul>) to display a list of items without any particular order.
- Use <li> tags to represent each item in the list.
5. Create an ordered list (<ol>) to display a list of items in a specific order.
- Use the type attribute of the <ol> tag to specify the numbering style (e.g., "I" for Roman
numerals).
- Use <li> tags to represent each item in the list.
6. Create a definition list (<dl>) to display a list of terms and their corresponding definitions.
- Use <dt> tags to represent each term.
- Use <dd> tags to represent each definition.
7. Close all HTML tags appropriately to ensure proper structure.

Program:4:

1. Create an HTML document with <html>, <head>, and <body> tags.


2. Set the title of the document using the <title> tag within the <head> section.
3. Create a form using the <form> tag to collect user input.
4. Add input fields within the form to gather information from the user:
- Text input for name, qualification, father's name, occupation, permanent address, nationality,
caste, email, and phone number.
- Date input for date of birth (DOB).
- Radio buttons for gender selection.
- Select dropdown for community selection.
- Number input for phone number.
5. Include a button within the form to allow users to submit the data.
6. Center the heading "Registration Form" using the <center> tag and <h1> tag.
7. Optionally, set the background color of the <body> section to blue.
8. Close all HTML tags appropriately to ensure proper structure.

Program-5:

1.The HTML document starts with <!DOCTYPE html> to specify the document type and
<html lang="en"> to specify the language of the document.

2.The <head> section contains meta tags for character encoding (<meta charset="UTF-8">)
and viewport settings (<meta name="viewport" content="width=device-width, initial-
scale=1.0">), as well as the title of the document specified within the <title> tag.

3. An anchor <a> tag is used to create a hyperlink.

4. The href attribute of the anchor tag specifies the URL to which the user should be directed
when the link is clicked.

5.Inside the anchor tag, an <img> tag is used to insert an image.

6.The src attribute of the <img> tag specifies the URL of the image to be displayed.

7.The alt attribute provides alternative text for the image, which is displayed if the image cannot
be loaded or by screen readers for accessibility.

8.The width and height attributes specify the dimensions of the image, in pixels.
9.The image file "rose.jpg" is expected to be located in the same directory as the HTML file or in
a directory accessible through the specified URL.

10.If the image file is not found, the specified alternative text will be displayed.

PHP PROGRAM:

Program:6: PHP function

1. Define a PHP function named myFamily that takes a last name and a variable number of first
names as parameters.

2. Initialize an empty string variable txt to store the greetings.

3. Calculate the number of first names passed to the function and store it in len.

4. Iterate through each first name using a for loop:

a. Concatenate a greeting message for each family member to the txt variable.

5. After the loop, return the concatenated string txt containing all the greetings.

6. Call the myFamily function with the last name "Doe" and multiple first names ("Jane", "John",
"Joey").

7. Assign the returned string to a variable a.


8. Output the value of variable a using echo.

Program-7:(PHP ARRAY)

1. Define a PHP function named is_multiArrayEmpty that takes a multi-dimensional array


as input.
2. The function checks if the input is an array and if it's not empty.
3. If the input is an array and not empty, it recursively checks the first element of the array
to determine if it's empty.
4. If the input is not an array or is empty, the function returns true.
5. If the input contains nested arrays, it recursively checks each nested array.
6. Define an array named $testCase containing various test cases to be evaluated by the
function.
7. Test cases include empty arrays, arrays with nested empty arrays, arrays with non-empty
values, and arrays with null values.
8. Use a foreach loop to iterate over each test case in the $testCase array.
9. For each test case, call the is_multiArrayEmpty function with the current test case as an
argument.
10. Output the index/key of the test case along with the result of the function call (true or
false) indicating whether the array is empty.
11. Output the results of the function calls for each test case, indicating whether the
corresponding array is empty or not.

PROGRAM-8(STRING FUNCTION IN PHP)

1. Define a PHP function reverseString($str) to reverse a given string.

- Use strrev($str) to reverse the input string.

- Return the reversed string.

2. Define a PHP function countWords($str) to count the number of words in a given string.

- Use str_word_count($str) to count the words in the input string.

- Return the count of words.

3. Define a sample input string $inputString.

4. Call reverseString($inputString) to reverse the input string and store the result in
$reversedString.
5. Call countWords($inputString) to count the number of words in the input string and store the
result in $numWords.

6. Output the original input string, the reversed string, and the number of words in the input
string.

PROGRAM 9:FORM HANDLING IN PHP

1. Display an HTML form with a text input field for entering the user's name.
2. Use the POST method to submit the form data to the same PHP script
($_SERVER['PHP_SELF']).
3. Check if the form has been submitted using
$_SERVER["REQUEST_METHOD"].
4. If the form has been submitted (POST method), proceed with processing the form
data.
5. Retrieve the value entered in the input field using $_REQUEST['fname'].
6. Sanitize the input using htmlspecialchars() to prevent XSS attacks.
7. Check if the input name is empty using empty().
8. If the name is empty, output the message "Name is empty".
9. If the input name is not empty, display the entered name.

PROGRAM:10:

Here's the algorithm for the PHP program provided:

1. Start or resume the session.

2. Check if the session variable 'counter' exists.

- If it does not exist:

- Initialize it to 1.

- If it exists:

- Increment its value by 1.

3. Display the current value of the session variable 'counter' as "Page views: [value]".
PROGRAM:11
1.TABLE CREATION:
Create a table client1 with required fields cno,name, add1, add2, city, state, incode, baldue

2.Insertion Algorithm:

Procedure InsertClient
Input: cno, name, add1, city, state, pincode, balancedue
Output: None

1. Prompt the user to input values for cno, name, add1, city, state, pincode, and balancedue.
2. Execute the SQL command to insert the provided values into the client1
table:
INSERT INTO clientmaster1 (cno, name, add1, city, state, pincode, balancedue)
VALUES (cno, 'name', 'add1', 'city', 'state', pincode, balancedue);
1. Display a message indicating the successful insertion of the record.

3.Query Algorithm
Procedure DisplayClients
Input: None
Output: None

1. Execute the SQL command to select all records from the clientmaster1 table:
SELECT * FROM clientmaster1;
2. Display the retrieved records to the user.
PROGRAM:12

1.Procedure ConnectToDatabase
1. Initialize connection parameters for the MySQL database (servername, username, password,
database).
2. Create a new mysqli connection object with the provided connection parameters.
3. Check if the connection was successful:
- If successful, return the connection object (conn).
- If unsuccessful, terminate the program with an error message.
2. Procedure RetrieveDataFromTable
1. Execute an SQL query to select data from the "users" table:
"SELECT id, name, email FROM users".
2. Execute the query using the database connection object (conn).
3. Check if the query returned any results:
- If results are found, return the result set.
- If no results are found, return a message indicating 0 results.
3.Procedure OutputData
1. Check if the result set contains any rows:
- If rows are present, iterate through each row in the result set:
- Display the ID, name, and email of each user row.
- If no rows are present, display a message indicating 0 results.
4.Procedure CloseDatabaseConnection

1. Close the database connection using the connection object (conn).

You might also like