From 7451edff7692e86c5238ff7bc6659825e242a84e Mon Sep 17 00:00:00 2001 From: Sudipto Mallick <> Date: Tue, 2 Jan 2024 03:38:10 +0000 Subject: Quick backup, need to be rewritten --- mysql-php/code/a1.php | 139 +++++++++++ mysql-php/code/a2.php | 78 ++++++ mysql-php/code/a3.php | 95 ++++++++ mysql-php/index.typ | 63 +++++ mysql-php/output/1/1.png | Bin 0 -> 38936 bytes mysql-php/output/1/2.png | Bin 0 -> 97622 bytes mysql-php/output/2.png | Bin 0 -> 75186 bytes mysql-php/sbld | 2 + mysql-php/text/a1.typ | 15 ++ mysql-php/text/a2.typ | 12 + mysql-php/tpl.typ | 53 +++++ mysql-php/vendor/gr.tmTheme | 566 ++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 1023 insertions(+) create mode 100644 mysql-php/code/a1.php create mode 100644 mysql-php/code/a2.php create mode 100644 mysql-php/code/a3.php create mode 100644 mysql-php/index.typ create mode 100644 mysql-php/output/1/1.png create mode 100644 mysql-php/output/1/2.png create mode 100644 mysql-php/output/2.png create mode 100755 mysql-php/sbld create mode 100644 mysql-php/text/a1.typ create mode 100644 mysql-php/text/a2.typ create mode 100644 mysql-php/tpl.typ create mode 100644 mysql-php/vendor/gr.tmTheme (limited to 'mysql-php') diff --git a/mysql-php/code/a1.php b/mysql-php/code/a1.php new file mode 100644 index 0000000..022b9ee --- /dev/null +++ b/mysql-php/code/a1.php @@ -0,0 +1,139 @@ + + +<?php echo $title; ?> + + +
+

Enter student's details

+ + + + + + + Show students' details +
+ +

Insertion successful.

+ +

Operation failed

+

Reason:

+ $desc) { + if (!isset($_POST[$name]) || empty($_POST[$name])) + display_failure('The ' . $desc . ' field can not be empty'); + $vars[$name] = $_POST[$name]; + } + return $vars; +} + +function insert_details($dbh) { + $vars = check_post_vars([ + 'name' => 'Name', + 'email' => 'E-mail address', + 'date_of_birth' => 'Date of birth', + 'city' => 'City', + 'roll' => 'Roll No.' + ]); + $stmt = mysqli_prepare($dbh, 'INSERT INTO STUDENT ( + ROLL, NAME, EMAIL, CITY, DATE_OF_BIRTH + ) VALUES (?,?,?,?,?)'); + mysqli_stmt_execute($stmt, [ + $vars['roll'], $vars['name'], $vars['email'], $vars['city'], + $vars['date_of_birth'] + ]); +} + +function show_table($dbh) { + $result = mysqli_query($dbh, 'SELECT * FROM STUDENT'); + html_prologue('Students\' details'); + ?> +

Students' details

+

record(s) found.

+ + + + + + + + + + +
Roll No.NameE-mailCityDate of birth
+ ', array_map('htmlspecialchars', [ + $row['ROLL'], $row['NAME'], $row['EMAIL'], $row['CITY'], + $row['DATE_OF_BIRTH'] + ])); ?> +
+ +

Operation failed

+

Reason:

+ + +<?php echo $title; ?> + + +

Students' details

+

The students who were born in years 2000 to 2005, inclusive.

+

record(s) found.

+ + + + + + + + + + +
Roll No.NameE-mailCityDate of birth
+ ', array_map('htmlspecialchars', [ + $row['ROLL'], $row['NAME'], $row['EMAIL'], $row['CITY'], + $row['DATE_OF_BIRTH'] + ])); ?> +
+ + +<?php echo $title; ?> + + +
+

Enter E-mail address to search for the record of a student

+ + +
+ +

Operation failed

+

Reason:

+ +

Students' details

+

record(s) found.

+ + + + + + + + + + +
Roll No.NameE-mailCityDate of birth
+ ', array_map('htmlspecialchars', [ + $row['ROLL'], $row['NAME'], $row['EMAIL'], $row['CITY'], + $row['DATE_OF_BIRTH'] + ])); ?> +
+ apply(body) +#let semibold(body) = text(weight: 600, body) +#text(size: 1.3em, align(center)[#semibold[Practical Assignments] \ _for_ \ #semibold[RDBMS Lab] \ _using_ \ #semibold[MySQL and PHP]]) +#set enum(full: true, numbering: (..args) => { + let patterns = ("1.", "(a)") + let pattern = patterns.at(calc.min(args.pos().len(), patterns.len()) - 1) + numbering(pattern, args.pos().last()) +}) + +#set raw(lang: "php") + ++ Create a table `Student` in a MySQL database containing the fields `name`, `roll`, `city`, `email` and `date_of_birth` and insert 5 records into this table and display them using PHP. ++ Write a PHP script to insert the records in the table in Question 2 and display the records in a separate table of all those students who were born in between `01/01/2000` to `31/12/2005`. ++ Design a HTML form to take a valid email from user and search the corresponding student from the database using PHP script and display the details of that student in tabular form. ++ Design a `Login` table to take `username` and `password`. Show all records of the `Student` table for an authorized user. A user if authorized when the username and password exists in the `Login` table of the MySQL database. ++ Design a Login form and check valid username and password to display student details using PHP script. Also write a PHP script allowing to change username and password. ++ Write PHP script to insert, delete and update records in a table. ++ Suppose a table `Food_Details` containing the fields `Food_items` and `Price_per_item`. Design a menu to select different food items and input the quantity ordered by customer. Generate a bill containing Customer name, Food items, quantity, price and Total price. Net price should be the total price plus 15% GST of total price. ++ Create a table as Question 7. Create another table `Customer_details` containing the fields `customer_name`, `total_amount_paid`, `date_of_payment`. Design a menu to select different food items and input the quantity ordered by customer. Generate a bill containing Customer name, Food items, quantity, and Total price. Also insert the record i.e. customer name, total amount paid and date of payment in `Customer_details` table. Net price should be the total price plus 15% GST of total price. ++ Suppose a table `Salary` contained the fields `EmpName`, `BasicPay`, `HRA`, `DA` and `Professional_tax`. Record should exists only for `EmpName` and `BasicPay`. Design a HTML form to take input for HRA percentage, DA percentage, and Professional tax. Now write a PHP script to generate the DA, HRA and Professional tax of every employee and store them into Salary table with respect to every employee. Now display the records. ++ Design a HTML form to take inputs from user and store the records into a table `Employee` using PHP script containing the following fields. + #align(center, tablex( + columns: 2, + auto-lines: false, + hlinex(), + vlinex(), vlinex(), vlinex(), + [*Fields*], [*Form input control*], + hlinex(), + [`Ename`], [textbox], + [`Address`], [textarea], + [`Phno`], [textbox], + [`Salary`], [textbox], + [`Category` \ (out of GEN, SC, ST, OBC)], [radio buttons], + [`Language`], [checkbox], + hlinex(), + )) + (Multiple languages have to be concatenate into a string separated by commas and then store into database like `Bengali, English, Hindi`.) ++ Write a PHP script to display the employee records of the above `Employee` table order by user’s choice field. The field have to be choices through drop down menu containing all fields of the table. ++ Create a table `Sports` in MySQL database containing the fields `Players`, `TestRuns`, `ODIRuns`, `T20IRuns`. Insert and display the record with total individual runs of every player (like `TestRun + ODIRun + T20IRun`) using PHP. ++ Display the record of highest run scorer in Test or T20I or ODI according to user’s choice through a drop down menu for the table in Question 13. Drop down menu contains the fields name `TestRuns`, `ODIRuns`, `T20IRuns`. ++ Design a HTML form to take records from user for the above table `Sports`. Now write PHP script to insert, update and delete records through PHP script. ++ Design a form to take input from user and store into a table containing the fields `name`, `city`, `phno`, `email`, `password`. Write a PHP script to take input and store into the table such that Phno and mail id of every person must be unique. ++ Create a MySQL database table `Employee` with fields `ename`, `eid`, `salary`, `dept` and `dob`. Perform all database operations like select, insert, delete and update through PHP. ++ Create a table `Marks` with the fields `stdname`, `roll`, `CompScMarks`, `PhysicsMarks`, `ChemistryMarks`. Design a form to insert records into database and display records with grade using PHP script. + #align(center, tablex( + columns: (8em, 4em), + auto-lines: false, + align: center + horizon, + colspanx(2)[$ m = ""$average marks of all subjects.], + hlinex(), + vlinex(start: 1), vlinex(start: 1), vlinex(start: 1), + [*Marks*], [*Grade*], + hlinex(), + [$80 <= m <= 100$], [A], + [$60 <= m < 80$], [B], + [$40 <= m < 60$], [C], + [$0 <= m < 40$], [D], + hlinex(), + )) ++ Create MySQL database table `Dept` with field `dno`, `dname` where `dno` is the primary key. Create another table `Employee` with field `eno`, `ename`, `city`, `salary`, `join_date`, `dno` where `eno` is the primary key and `dno` is a foreign key reference to the `Dept` table. Include other constraints like `NOT NULL`, `CHECK` etc. Perform all database operation like select, insert, update, and delete using PHP. (Query may include `group by`, `having`, `order by`, aggregate functions, `like` operator.) + diff --git a/mysql-php/output/1/1.png b/mysql-php/output/1/1.png new file mode 100644 index 0000000..a165e62 Binary files /dev/null and b/mysql-php/output/1/1.png differ diff --git a/mysql-php/output/1/2.png b/mysql-php/output/1/2.png new file mode 100644 index 0000000..8d99484 Binary files /dev/null and b/mysql-php/output/1/2.png differ diff --git a/mysql-php/output/2.png b/mysql-php/output/2.png new file mode 100644 index 0000000..b324c1c Binary files /dev/null and b/mysql-php/output/2.png differ diff --git a/mysql-php/sbld b/mysql-php/sbld new file mode 100755 index 0000000..33a51ed --- /dev/null +++ b/mysql-php/sbld @@ -0,0 +1,2 @@ +#!/bin/sh +typst ${2:-c} --root $PWD text/a$1.typ docs/s$1.pdf diff --git a/mysql-php/text/a1.typ b/mysql-php/text/a1.typ new file mode 100644 index 0000000..efdc981 --- /dev/null +++ b/mysql-php/text/a1.typ @@ -0,0 +1,15 @@ +#import "/tpl.typ": * +#show: A => apply(A) +#set raw(lang: "php") +#set par(leading: 0.725em) + +#assignment(1)[ + Create a table `Student` in a MySQL database containing the fields `name`, `roll`, `city`, `email` and `date_of_birth` and insert 5 records into this table and display them using PHP. +] + +#scos(1)[ + === Form page + #align(center, image("/output/1/1.png", width: 60%)) + === Display record + #image("/output/1/2.png", width: 100%) +] diff --git a/mysql-php/text/a2.typ b/mysql-php/text/a2.typ new file mode 100644 index 0000000..989f30f --- /dev/null +++ b/mysql-php/text/a2.typ @@ -0,0 +1,12 @@ +#import "/tpl.typ": * +#show: A => apply(A) +#set raw(lang: "php") +#set par(leading: 0.65em) + +#assignment(2)[ + Write a PHP script to insert the records in the table in Assignment 1 and display the records in a separate table of all those students who were born in between `01/01/2000` to `31/12/2005`. +] + +#scos(2)[ + #image("/output/2.png", width: 100%) +] diff --git a/mysql-php/tpl.typ b/mysql-php/tpl.typ new file mode 100644 index 0000000..1179925 --- /dev/null +++ b/mysql-php/tpl.typ @@ -0,0 +1,53 @@ +#import "@preview/codelst:1.0.0": sourcefile +#let hlfile(filename) = sourcefile(read(filename), file: filename) +#let apply(body) = { + let body-font-settings = (font: "Nunito Sans 10pt", size: 12pt, stretch: 75%) +// let body-font-settings = (font: "Hanken Grotesk", size: 12pt, stretch: 75%) + let page-margin = (left: 0.75in, right: 0.25in, top: 0.5in, bottom: 0.25in) + let margin = (left: 0.75in, right: 0.25in, top: 2em, bottom: 2em) + let page-frame-thickness = 1.5pt + set page( + margin: (..page-margin, bottom: margin.bottom + 2em), + numbering: "1", + background: align(top + start, pad(..margin, rect(width: 100%, height: 100%, stroke: page-frame-thickness + gray))), + footer: locate(loc => align(center, move(dy: -margin.bottom + 1em, text(..body-font-settings, size: 9pt, counter(page).display(loc.page-numbering()))))) + ) + show: block.with(breakable: true, width: 100%, inset: page-frame-thickness + 1em) + + set text(..body-font-settings) + + let code-color = rgb("#f4f4f4") +// show raw: set text(font: "CommitMono", size: 1.1em) +// show raw: set text(font: "Source Code Pro", size: 1.1em) + show raw: set text(font: "Iosevka Fixed", size: 10pt) + show raw.where(block: false): box.with( + fill: code-color, + inset: (x: 3pt, y: 0pt), + outset: (y: 3pt), + radius: 2pt, + ) + show raw.where(block: true): block.with( + fill: code-color, + inset: 10pt, + radius: 4pt, + width: 100%, + ) + show raw.where(block: true): it => align(left, it) + set raw(theme: "vendor/gr.tmTheme") + set par(leading: 0.6em) + body +} + +#let assignment(number, description) = align(center, [ += #text(weight: 600, [Assignment #number]) +== #text(weight: 500, [Program description:]) #text(weight: 400, description) +]) +#let objective(body) = align(center, [*Objective*: #body]) +#let oset(kind) = block(spacing: 0.6em, [===== #h(1em) #kind]) + +#let scos(n, obody) = { + [=== Source Code] + hlfile("/code/a" + str(n) + ".php") + [=== Output] + obody +} diff --git a/mysql-php/vendor/gr.tmTheme b/mysql-php/vendor/gr.tmTheme new file mode 100644 index 0000000..c4ab8f1 --- /dev/null +++ b/mysql-php/vendor/gr.tmTheme @@ -0,0 +1,566 @@ + + + + + author + Template: Chris Kempson, Scheme: Alexandre Gavioli (https://github.com/Alexx2/) + name + Base16 Grayscale Light + semanticClass + theme.base16.grayscale-light + colorSpaceName + sRGB + gutterSettings + + background + #e3e3e3 + divider + #e3e3e3 + foreground + #ababab + selectionBackground + #b9b9b9 + selectionForeground + #525252 + + settings + + + settings + + background + #f7f7f7 + caret + #464646 + foreground + #464646 + invisibles + #ababab + lineHighlight + #ababab55 + selection + #b9b9b9 + + + + name + Text + scope + variable.parameter.function + settings + + foreground + #222222 + + + + name + Comments + scope + comment, punctuation.definition.comment + settings + + foreground + #777777 + fontStyle + bold + + + + name + Punctuation + scope + punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array + settings + + foreground + #111111 + + + + name + Delimiters + scope + none + settings + + foreground + #222222 + + + + name + Operators + scope + keyword.operator + settings + + foreground + #222222 + + + + name + Keywords + scope + keyword + settings + + foreground + #333333 + fontStyle + bold + + + + name + Variables + scope + variable + settings + + foreground + #555555 + + + + name + Functions + scope + entity.name.function, meta.require, support.function.any-method, variable.function, variable.annotation, support.macro + settings + + foreground + #444444 + + + + name + Labels + scope + entity.name.label + settings + + foreground + #5e5e5e + + + + name + Classes + scope + support.class, entity.name.class, entity.name.type.class + settings + + foreground + #666666 + + + + name + Classes + scope + meta.class + settings + + foreground + #101010 + + + + name + Methods + scope + keyword.other.special-method + settings + + foreground + #444444 + + + + name + Storage + scope + storage + settings + + foreground + #444444 + fontStyle + bold + + + + name + Support + scope + support.function + settings + + foreground + #868686 + + + + name + Strings, Inherited Class + scope + string, constant.other.symbol, entity.other.inherited-class + settings + + foreground + #333333 + + + + name + Integers + scope + constant.numeric + settings + + foreground + #000000 + + + + name + Floats + scope + none + settings + + foreground + #000000 + + + + name + Boolean + scope + none + settings + + foreground + #222222 + + + + name + Constants + scope + constant + settings + + foreground + #000000 + + + + name + Tags + scope + entity.name.tag + settings + + foreground + #7c7c7c + + + + name + Attributes + scope + entity.other.attribute-name + settings + + foreground + #999999 + + + + name + Attribute IDs + scope + entity.other.attribute-name.id, punctuation.definition.entity + settings + + foreground + #686868 + + + + name + Selector + scope + meta.selector + settings + + foreground + #747474 + + + + name + Values + scope + none + settings + + foreground + #999999 + + + + name + Headings + scope + markup.heading punctuation.definition.heading, entity.name.section + settings + + fontStyle + + foreground + #686868 + + + + name + Units + scope + keyword.other.unit + settings + + foreground + #999999 + + + + name + Bold + scope + markup.bold, punctuation.definition.bold + settings + + fontStyle + bold + foreground + #a0a0a0 + + + + name + Italic + scope + markup.italic, punctuation.definition.italic + settings + + fontStyle + italic + foreground + #747474 + + + + name + Code + scope + markup.raw.inline + settings + + foreground + #8e8e8e + + + + name + Link Text + scope + string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown + settings + + foreground + #7c7c7c + + + + name + Link Url + scope + meta.link + settings + + foreground + #999999 + + + + name + Lists + scope + markup.list + settings + + foreground + #7c7c7c + + + + name + Quotes + scope + markup.quote + settings + + foreground + #999999 + + + + name + Separator + scope + meta.separator + settings + + background + #b9b9b9 + foreground + #464646 + + + + name + Inserted + scope + markup.inserted + settings + + foreground + #8e8e8e + + + + name + Deleted + scope + markup.deleted + settings + + foreground + #7c7c7c + + + + name + Changed + scope + markup.changed + settings + + foreground + #747474 + + + + name + Colors + scope + constant.other.color + settings + + foreground + #868686 + + + + name + Regular Expressions + scope + string.regexp + settings + + foreground + #868686 + + + + name + Escape Characters + scope + constant.character.escape + settings + + foreground + #868686 + + + + name + Embedded + scope + punctuation.section.embedded, variable.interpolation + settings + + foreground + #747474 + + + + name + Illegal + scope + invalid.illegal + settings + + background + #7c7c7c + foreground + #101010 + + + + name + Broken + scope + invalid.broken + settings + + background + #999999 + foreground + #f7f7f7 + + + + name + Deprecated + scope + invalid.deprecated + settings + + background + #5e5e5e + foreground + #101010 + + + + name + Unimplemented + scope + invalid.unimplemented + settings + + background + #ababab + foreground + #101010 + + + + uuid + uuid + + -- cgit 1.4.1-2-gfad0