-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertSampleData.php
More file actions
192 lines (160 loc) · 6.5 KB
/
insertSampleData.php
File metadata and controls
192 lines (160 loc) · 6.5 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
$name_list=['James','John','Robert','Michael','William','David','Richard','Charles','Joseph','Thomas','Christopher','Daniel','Paul','Mark','Donald','George','Kenneth','Steven','Edward','Brian','Ronald','Anthony','Kevin','Jason','Matthew','Mary','Patricia','Linda','Barbara','Elizabeth','Jennifer','Maria','Susan','Margaret','Dorothy','Lisa','Nancy','Karen','Betty','Helen','Sandra','Donna','Carol','Ruth','Sharon','Michelle','Laura','Sarah','Eric','Stephen','Andrew','Raymond','Gregory','Joshua','Jerry','Dennis','Walter','Kimberly','Deborah','Jessica','Shirley','Cynthia','Angela'];
$data = [
["1", "HS3152", "Professional English - I", "Pass"],
["1", "MA3151", "Matrices and Calculus", "Pass"],
["1", "PH3151", "Engineering Physics", "Pass"],
["1", "CY3151", "Engineering Chemistry", "Pass"],
["1", "GE3151", "Problem Solving and Python Programming", "Pass"],
[
"1",
"GE3171",
"Laboratory Problem Solving and Python Programming",
"Pass",
],
["1", "BS3171", "Laboratory Physics and Chemistry", "Pass"],
["1", "GE3172", "Laboratory English", "Pass"],
["2", "HS3252", "Professional English - II", "Pass"],
["2", "MA3251", "Engineering Mathematics - II", "Pass"],
["2", "PH3256", "Physics for Information Science", "Pass"],
["2", "BE3251", "Basic Electrical and Electronics Engineering", "Pass"],
["2", "GE3251", "Engineering Graphics", "Pass"],
["2", "CS3251", "Programming in C", "Pass"],
["2", "GE3271", "Laboratory Engineering Practices", "Pass"],
["2", "CS3271", "Laboratory Programming in C", "Pass"],
["2", "GE3272", "Laboratory Communication", "Pass"],
["3", "MA3354", "Discrete Mathematics", "Pass"],
["3", "CS3351", "Digital Principles and Computer Organization", "Pass"],
["3", "CS3352", "Foundations of Data Science", "Pass"],
["3", "CS3301", "Data Structures", "Pass"],
["3", "CS3391", "Object Oriented Programming", "Pass"],
["3", "CS3311", "Laboratory Data Structures", "Pass"],
["3", "CS3381", "Laboratory Object Oriented Programming", "Pass"],
["3", "CS3361", "Laboratory Data Science ", "Pass"],
["3", "GE3361", "Professional Development", "Pass"],
["4", "CS3452", "Theory of Computation", "Pass"],
["4", "CS3491", "Artificial Intelligence and Machine Learning", "Pass"],
["4", "CS3492", "Database Management Systems", "Pass"],
["4", "CS3401", "Algorithms", "Pass"],
["4", "CS3451", "Introduction to Operating Systems", "Pass"],
["4", "GE3451", "Environmental Sciences and Sustainability", "Pass"],
["4", "CS3461", "Laboratory Operating Systems", "Pass"],
["4", "CS3481", "Laboratory Database Management Systems", "Pass"],
["5", "CS3591", "Computer Networks", "Pass"],
["5", "CS3501", "Compiler Design", "Pass"],
["5", "CB3491", "Cryptography and Cyber Security", "Pass"],
["5", "CS3551", "Distributed Computing", "Pass"],
["6", "CCS356", "Software Engineering", "Pass"],
["6", "CS3691", "Embedded Systems and IoT", "Pass"],
["6", "CCS351", "Modern Cryptography", "Pass"],
["7", "CCS335", "Cloud Computing", "Pass"],
["7", "GE3791", "Human Values and Ethics", "Pass"],
["7", "GE3754", "Human Resource Management", "Pass"],
["8", "GE3751", "Principles of Management", "Pass"],
["8", "CS3811", "Project Work", "Pass"],
];
// dummy values to insert into the database for testcacse running
/*
$conn = new mysqli("localhost", "id21666751_markdatabase", "Arun_marks1.4");
// Create database
$sql = "CREATE DATABASE mark";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully" , '<br>' ;
} else {
echo "Error creating database: " . $conn->error;
}
mysqli_close($conn);
*/
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mark";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// sql to create table
$sql = "CREATE TABLE IF NOT EXISTS Marks (
Regno BIGINT(12) UNSIGNED ,
Name VARCHAR(50) NOT NULL,
Sem1 VARCHAR(100),
Sem2 VARCHAR(100),
Sem3 VARCHAR(100),
Sem4 VARCHAR(100),
Sem5 VARCHAR(100),
Sem6 VARCHAR(100),
Sem7 VARCHAR(100),
Sem8 VARCHAR(100),
Total INT(3) UNSIGNED )";
if ($conn->query($sql) === true) {
echo "Table marks created successfully", "<br>";
} else {
echo "Error creating table: " . $conn->error;
}
$sql = $conn->prepare(
"INSERT INTO Marks (Regno, Name, Sem1, Sem2, Sem3, Sem4, Sem5, Sem6, Sem7, Sem8, Total) VALUES (?,?,?,?,?,?,?,?,?,?,?) "
);
$sql->bind_param(
"isssssssssi",
$regnum,
$name,
$Sem1,
$Sem2,
$Sem3,
$Sem4,
$Sem5,
$Sem6,
$Sem7,
$Sem8,
$Total
);
for ($loopvar1 = 0; $loopvar1 < 60; $loopvar1++) {
$regnum = "620125104" . substr("0000{$loopvar1}", -3);
$name = $name_list[$loopvar1];
$loopvar3 = 0; //for count of total subjects
$Sem1 = $data[rand(0, count($data) - 1)][1];
for ($loopvar2 = 0; $loopvar2 < rand(1, 2); $loopvar2++) {
$loopvar3++;
$Sem1 = $Sem1 . "," . $data[rand(0, count($data) - 1)][1];
}
$Sem2 = $data[rand(0, count($data) - 1)][1];
for ($loopvar2 = 0; $loopvar2 < rand(1, 2); $loopvar2++) {
$loopvar3++;
$Sem2 = $Sem2 . "," . $data[rand(0, count($data) - 1)][1];
}
$Sem3 = $data[rand(0, count($data) - 1)][1];
for ($loopvar2 = 0; $loopvar2 < rand(1, 2); $loopvar2++) {
$loopvar3++;
$Sem3 = $Sem3 . "," . $data[rand(0, count($data) - 1)][1];
}
$Sem4 = $data[rand(0, count($data) - 1)][1];
for ($loopvar2 = 0; $loopvar2 < rand(1, 2); $loopvar2++) {
$loopvar3++;
$Sem4 = $Sem4 . "," . $data[rand(0, count($data) - 1)][1];
}
$Sem5 = $data[rand(0, count($data) - 1)][1];
$Sem6 = $data[rand(0, count($data) - 1)][1];
for ($loopvar2 = 0; $loopvar2 < rand(1, 2); $loopvar2++) {
$loopvar3++;
$Sem6 = $Sem6 . "," . $data[rand(0, count($data) - 1)][1];
}
$Sem7 = $data[rand(0, count($data) - 1)][1];
$Sem8 = $data[rand(0, count($data) - 1)][1];
for ($loopvar2 = 0; $loopvar2 < rand(1, 2); $loopvar2++) {
$loopvar3++;
$Sem8 = $Sem8 . "," . $data[rand(0, count($data) - 1)][1];
}
//+8 for each sem first data entered without loop
$Total = $loopvar3 + 8;
if ($sql->execute()) {
echo "New record {$regnum} created successfully", "<br>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
} //for loopvar1
$sql->close;
$conn->close();
?>