summary refs log tree commit diff stats
path: root/mysql-php/text
diff options
context:
space:
mode:
authorSudipto Mallick <smlckz@termux-alpine>2024-02-08 11:08:33 +0000
committerSudipto Mallick <smlckz@termux-alpine>2024-02-08 11:08:33 +0000
commit02884d29e4f5aea71364a203dcaecd53600d8aa4 (patch)
tree0047b71f3677132fd6319919233e8ce5da43ad6d /mysql-php/text
parent0ac38a6f4ce7144635525a5a73bf2946d2909fa6 (diff)
downloadzadania-02884d29e4f5aea71364a203dcaecd53600d8aa4.tar.gz
Complete PHP assignments
Diffstat (limited to 'mysql-php/text')
-rw-r--r--mysql-php/text/a1.typ13
-rw-r--r--mysql-php/text/a2.typ8
-rw-r--r--mysql-php/text/a3.typ13
-rw-r--r--mysql-php/text/a4.typ17
-rw-r--r--mysql-php/text/a5.typ42
5 files changed, 68 insertions, 25 deletions
diff --git a/mysql-php/text/a1.typ b/mysql-php/text/a1.typ
index 416d56c..f4d918b 100644
--- a/mysql-php/text/a1.typ
+++ b/mysql-php/text/a1.typ
@@ -27,15 +27,4 @@
   #align(center, image("/output/1/7.png", width: 80%))
 ]
 
-== Records in `STUDENTS_DB.STUDENT`
-#table(
-    columns: 5,
-    [*`ROLL`*], [*`NAME`*], [*`CITY`*], [*`EMAIL`*], [*`DATE_OF_BIRTH`*],
-    [`24354946`], [`Hu Shengti`], [`Chengdu`], [`hst@m15342.cn`], [`2001-05-10`], 
-    [`35464647`], [`Albert Rechtsburger`], [`Düsseldorf`], [`arb@gmx.de`], [`1999-06-17`], 
-    [`76879140`], [`Nora Akagami`], [`Nara`], [`norakiki@mail.co.jp`], [`2002-07-04`], 
-    [`78324598`], [`Grzegorz Brzezinski`], [`Łódź`], [`grzbrzski@fastmail.com`], [`1997-07-04`], 
-    [`89764243`], [`Park Jihoon`], [`Busan`], [`pjh2346@naver.com`], [`2002-10-01`], 
-    [`97381425`], [`Mark Sanders`], [`San Francisco`], [`marksanders@gmail.com`], [`2004-03-24`], 
-)
-
+#signature()
diff --git a/mysql-php/text/a2.typ b/mysql-php/text/a2.typ
index 1f3c115..869745c 100644
--- a/mysql-php/text/a2.typ
+++ b/mysql-php/text/a2.typ
@@ -10,5 +10,11 @@
 ]
 
 #scos(2)[
-    #image("/output/2.png", width: 100%)
+  #{ /* image("/output/2.png", width: 100%)*/ []}
+  === Login form
+  #image("/output/2/1.png", width: 80%)
+  === Display records on success
+  #image("/output/2/2.png", width: 90%)
 ]
+
+#signature()
diff --git a/mysql-php/text/a3.typ b/mysql-php/text/a3.typ
index 9f30e6c..4a48b48 100644
--- a/mysql-php/text/a3.typ
+++ b/mysql-php/text/a3.typ
@@ -14,15 +14,4 @@
   #align(center, image("/output/3/2.png", width: 70%))
 ]
 
-== Records in `STUDENTS_DB.STUDENT`
-#table(
-    columns: 5,
-    [*`ROLL`*], [*`NAME`*], [*`CITY`*], [*`EMAIL`*], [*`DATE_OF_BIRTH`*],
-    [`24354946`], [`Hu Shengti`], [`Chengdu`], [`hst@m15342.cn`], [`2001-05-10`], 
-    [`35464647`], [`Albert Rechtsburger`], [`Düsseldorf`], [`arb@gmx.de`], [`1999-06-17`], 
-    [`76879140`], [`Nora Akagami`], [`Nara`], [`norakiki@mail.co.jp`], [`2002-07-04`], 
-    [`78324598`], [`Grzegorz Brzezinski`], [`Łódź`], [`grzbrzski@fastmail.com`], [`1997-07-04`], 
-    [`89764243`], [`Park Jihoon`], [`Busan`], [`pjh2346@naver.com`], [`2002-10-01`], 
-    [`97381425`], [`Mark Sanders`], [`San Francisco`], [`marksanders@gmail.com`], [`2004-03-24`], 
-)
-
+#signature()
diff --git a/mysql-php/text/a4.typ b/mysql-php/text/a4.typ
new file mode 100644
index 0000000..ec5d8e6
--- /dev/null
+++ b/mysql-php/text/a4.typ
@@ -0,0 +1,17 @@
+#import "/tpl.typ": *
+#show: A => apply(A)
+#set raw(lang: "php")
+#set par(leading: 0.7em)
+
+#assignment(4)[
+  Create an HTML form to input employee salary components such as Basic Pay, House Rent Allowance (HRA) percentage, Dearness Allowance (DA) percentage, and Professional Tax. Upon submission, the PHP script should calculate the HRA, DA, and Professional Tax for each employee based on the provided percentages and store these details in a database table named `Salary`. Ensure that records in the `Salary` table contain entries only for employee names and basic pay. Finally, display the stored salary records including employee names, basic pay, calculated HRA, DA, and Professional Tax.
+]
+
+#scos(4, cont: true)[
+  === Login form
+  #image("/output/4/1.png", width: 60%)
+  === Display records
+  #image("/output/4/2.png", width: 80%)
+]
+
+#signature()
diff --git a/mysql-php/text/a5.typ b/mysql-php/text/a5.typ
new file mode 100644
index 0000000..4f63dfc
--- /dev/null
+++ b/mysql-php/text/a5.typ
@@ -0,0 +1,42 @@
+#import "@preview/tablex:0.0.6": tablex, vlinex, hlinex
+#import "/tpl.typ": *
+#show: A => apply(A)
+#set raw(lang: "php")
+#set par(leading: 0.7em)
+
+#assignment(5)[
+  Design a HTML form to take inputs from the user and store the records into a table `Employee` using a PHP script. The form should contain 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 concatenated into a string separated by commas and then stored into the database like `Bengali, English, Hindi`.)
+
+  Once the form is submitted, the PHP script should process the input data and insert a new record into the `Employee` table in the database. Ensure that appropriate validation is implemented to handle user input correctly.
+
+  Additionally, implement functionality to display the employee records from the `Employee` table. The records should be ordered based on the user's choice of field, which can be selected from a dropdown menu containing all fields of the table. Optionally, provide a checkbox to allow the user to specify descending order for the displayed records.
+]
+
+#scos(5, cont: true)[
+  === Menu
+  #align(center, image("/output/5/1.png", width: 20%))
+  === Input Form
+  #align(center, image("/output/5/2.png", width: 30%))
+  === Display records
+  #align(center, image("/output/5/3.png", width: 90%))
+  #align(center, image("/output/5/4.png", width: 90%))
+]
+
+#signature()
tik.com> 2021-08-10 04:44:43 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2021-08-10 04:44:43 -0700 .' href='/akkartik/mu/commit/browse_slack/convert_slack.py?h=hlt&id=5456a1edcb9716bede78309fb76da3763ba54cd4'>5456a1ed ^
49352e16 ^
5456a1ed ^
74dad4c4 ^








49dacb60 ^
98b11ea6 ^
5456a1ed ^


74dad4c4 ^


ed068e85 ^
5456a1ed ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                                                                      
 
                                              
 
                                                                  

                                                                                                           
                                                                                                                                                

                
                                     






                                                                                                       
                                                                
                                                       
                                                     
                                                          

                                                                                                                         
                                                                                    
                                                                                                









                                                                                     

                                                         
                                            



                                 
             
                             
                                             


                                                                                                                                                         
                                  
 
             
                                 
 








                                                               
                                                
                                                     


                                                        


                                                                                                                                           
                                                                                         

                                                 
# Import JSON from a Slack admin export into a disk image Mu can load.
#
# Dependencies: python, wget, awk, sed, netpbm
#
# Step 1: download a Slack archive and unpack it to some directory
#
# Step 2: download user avatars to subdirectory images/ and convert them to PPM in subdirectory images/ppm/
#   grep image_72 . -r |grep -v users.json |awk '{print $3}' |sort |uniq |sed 's/?.*//' |sed 's,\\,,g' |sed 's/"//' |sed 's/",$//' > images.list
#   mkdir images
#   cd images
#   wget -i ../images.list --wait=0.1
#   # fix some lying images
#   for f in $(file *.jpg |grep PNG |sed 's/:.*//'); do mv -i $f $(echo $f |sed 's/\.jpg$/.png/'); done
#   #
#   mkdir ppm
#   for f in *.jpg; do jpegtopnm $f |pnmtopnm -plain > ppm/$(echo $f |sed 's/\.jpg$//').ppm; done
#   for f in *.png; do png2pnm -n $f > ppm/$(echo $f |sed 's/\.png$//').ppm; done
#
# Step 3: construct a disk image out of the archives and avatars
#   cd ..  # go back to the top-level archive directory
#   dd if=/dev/zero of=data.img count=201600  # 100MB
#   python path/to/convert_slack.py > data.out 2> data.err
#   (optionally sort items by timestamp; I currently do this in Vim by piping the latter half of data.out through `sort`)
#   dd if=data.out of=data.img conv=notrunc
# Currently this process yields errors for ~300 items (~70 posts and their comments)
# on the Future of Software group (https://futureofcoding.org/community). We fail to load those.
#
# Notes on input format:
#   Redundant 'type' field that's always 'message'. Probably an "enterprise" feature.

from sys import argv, stderr
import json
from os import listdir
from os.path import isfile, join, basename, splitext
from urllib.parse import urlparse

def look_up_ppm_image(url):
    file_root = splitext(basename(urlparse(url).path))[0]
    filename = f"images/ppm/{file_root}.ppm"
    if isfile(filename):
        with open(filename) as f:
            return f.read()

user_idx = {}
with open('users.json') as f:
    for idx, user in enumerate(json.load(f)):
        if 'real_name' not in user:
            user['real_name'] = ''
        print(f"({json.dumps(user['id'])} \"@{user['name']}\" {json.dumps(user['real_name'])} [{look_up_ppm_image(user['profile']['image_72']) or ''}])")
        user_idx[user['id']] = idx

def by(item):
    return user_idx[item['user']]

item_idx = {}
def parent(item):
    if 'thread_ts' in item and item['thread_ts'] != item['ts']:
        # comment
        return item_idx[item['thread_ts']]
    else:
        return -1

idx = 0
for channel in json.load(open('channels.json')):
    for filename in sorted(listdir(channel['name'])):
        with open(join(channel['name'], filename)) as f:
            for item in json.load(f):
                try:
#?                     stderr.write(repr(item)+'\n')
                    print(f"({json.dumps(item['ts'])} {parent(item)} {json.dumps(channel['name'])} {by(item)} {json.dumps(item['text'])})")
                    item_idx[item['ts']] = idx
                    idx += 1  # only increment when actually used and no exception raised
                except KeyError:
                    stderr.write(repr(item)+'\n')