-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadData.php
132 lines (123 loc) · 3.29 KB
/
loadData.php
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WebMed</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css"
integrity="sha256-+N4/V/SbAFiW1MPBCXnfnP9QSN3+Keu+NlB+0ev/YKQ="
crossorigin="anonymous"
/>
<!--bootstrap-->
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
<link rel="shortcut icon" href="images/favicon.png" />
<!--font awesome-->
<script
src="https://use.fontawesome.com/releases/v5.13.0/js/all.js"
data-auto-replace-svg="nest"
></script>
</head>
<body>
<div class="top-container" id="top-container">
<h2 class="hotline" id="makecall">Hotline: +8801xxxxxxxxx</h2>
</div>
<?php
#echo "ok";
function fun()
{
$conn = new mysqli("localhost","root", "", "medicine");
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "CREATE TABLE medinfo (
DrugName VARCHAR(50),
Form VARCHAR(50),
Strength VARCHAR(50),
Indication VARCHAR(90)
)";
if ($conn->query($sql) === TRUE) {
echo "Table MyMED created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
$newrow=0;
if (($handle = fopen("medicine_info.csv", "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 500, ",")) !== FALSE)
{
$newrow++;
$p=$data[5];
$q=$data[2];
$r=$data[3];
$s=$data[8];
$sql = "INSERT INTO medinfo (DrugName,Form,Strength,Indication) VALUES ('$p', '$q', '$r','$s')";
if ($conn->query($sql) === TRUE)
{
echo "Done";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
if($newrow>=1200)
{
break;
}
}
fclose($handle);
}
}
function fun2()
{
$conn = new mysqli("localhost","root", "", "medicine");
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "CREATE TABLE docinfo (
DocID INT,
DocName VARCHAR(50),
DocSpeciality VARCHAR(50),
DocEmail VARCHAR(50),
DocPhone VARCHAR(90)
)";
if ($conn->query($sql) === TRUE) {
echo "Table MyDOC created successfully";
} else {
echo "Error creating table: " . $conn->error;
}
if (($handle = fopen("doc_info.csv", "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 500, ",")) !== FALSE)
{
$p=$data[0];
$q=$data[1];
$r=$data[2];
$s=$data[3];
$t=$data[4];
$sql = "INSERT INTO docinfo (DocID,DocName,DocSpeciality,DocEmail,DocPhone) VALUES ('$p', '$q', '$r','$s','$t')";
if ($conn->query($sql) === TRUE)
{
echo "Done";
}
else
{
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
fclose($handle);
}
}
fun();
fun2();
?>
</body>
</html>