-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsponsor1.php
213 lines (193 loc) · 5.28 KB
/
sponsor1.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
require('db.php');
?>
<html>
<head>
<title></title>
<!-- <link rel = "stylesheet" type="text/css" href="css/style.css"/> -->
<link rel="stylesheet" type="text/css" href="Horizontal.css">
<style>
body
{
background-image:url("images/yellow.jpg");
background-repeat:no-repeat;
background-size: cover;
margin-left:200px;
margin-right:200px;
margin-top:100px;
}
table
{
background-color:#BAC8DF;
border-radius:20px;
border:1px solid;
}
.table
{
background-color:white;
border-radius:20px;
font-color:white;
opacity:0.8;
text-align: center;
}
form{
text-align:justify;
font-size:20px;
}
input
{
border-radius: 17px;
border-radius: 17px;
border-radius: 17px;
border-radius: 17px;
border:solid 1px;
padding:10px;
}
.text
{
width:200px;
}
.button
{
background-color: white;
border:2px solid #484646;
width:200px;
color: black;
padding: none;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
.button:hover
{
background-color: #392F2F;
color: white;
}
.submit
{
width: 95px;
}
.box
{
width: 295px;
}
.change
{
width: 130px;
}
h1
{
text-align: center;
}
</style>
</head>
<body>
<table>
<div class="container">
<div class="wrapper">
<h1>SPONSORED KID</h1>
</div>
<div class="data">
<form action="" method="POST" >
<select name="usern">
<option>STUDENT</option>
<?php
$query1 = "SELECT usern FROM sponsorship WHERE status='no'";
$result1 = $con->query($query1);
while($rows1 = mysqli_fetch_array($result1)) //mysqli_fetch_array is used to return an array
{
$sid = $rows1['usern']; //storing the value selected form the displayed lsit
$rowsData1 = $rows1['usern']; //displaying the values from the table
?>
<option value="<?php echo $sid;?>"><?php echo $rowsData1;?></option> 
<?php
}
?>
</select>    
<input type="submit" name="submit" class="submit"/>
<table border="1" class="table" cellpadding="7"><br>
<tr>
<th>Student username</th>
<th>Student status</th>
<th>Student First Name</th>
<th>Student Last Name</th>
<th>Student Annual Income</th>
<th>Institution Name</th>
<th>Course Name</th>
<th>Fees Paid</th>
</tr>
<tr>
<?php
if(isset($_POST['submit'])){
$sponsorkid = $_POST['usern']; //storing the selected value in the php variable
$query3 = "SELECT sponsorship.usern, sponsorship.status, personal.firstname, personal.lastname,family.tincome, education.insdeg, education.ccourse, fees.total FROM sponsorship LEFT JOIN personal ON sponsorship.usern=personal.usern LEFT JOIN family ON sponsorship.usern=family.usern LEFT JOIN education ON sponsorship.usern=education.usern LEFT JOIN fees ON sponsorship.usern=fees.usern WHERE sponsorship.usern = '$sponsorkid'";
$result3 = $con->query($query3);
while($rows3 = mysqli_fetch_array($result3)){
$studentFName = $rows3['usern'];
$studentLName = $rows3['status'];
$studentFirst = $rows3['firstname'];
$studentLast = $rows3['lastname'];
$studentannual = $rows3['tincome'];
$studentins = $rows3['insdeg'];
$studentcourse = $rows3['ccourse'];
$studenttot = $rows3['total'];
?>
<tr>
<td><?php echo $studentFName; ?></td>
<td><?php echo $studentLName; ?></td>
<td><?php echo $studentFirst; ?></td>
<td><?php echo $studentLast; ?></td>
<td><?php echo $studentannual; ?></td>
<td><?php echo $studentins; ?></td>
<td><?php echo $studentcourse; ?></td>
<td><?php echo $studenttot; ?></td>
</tr>
<?php
}
}
?>
</tr>
<br>
</table><br>
<br><input type="text" name="username2" placeholder="enter the username of the student" class="box">    
<?php
$usern2 = $_GET['q'];
?>
<input type="text" class="text" name="sponsorname" placeholder="Username" value="<?php echo $usern2?>" required><br><br>
    
<input type="text" name="sponsoramount" placeholder="amount" class="box">
<br><br>
<input type="submit" name="changestatus" value="change status" class="change"/>
<?php
if(isset($_POST['changestatus'])){
$sponsorkid2 = $_POST['username2'];
$sponsor = $_POST['sponsorname'];
$sponsoramount = $_POST['sponsoramount'];
$trn_date = date("Y-m-d H:i:s");
$query4 = "UPDATE sponsorship SET status='yes' WHERE usern = '$sponsorkid2'";
$query5 = "INSERT into `sponsored` (usern,sponusern,amount,trn_date) VALUES ('$sponsorkid2','$sponsor','$sponsoramount',
'$trn_date')";
$result4 = $con->query($query4);
$result5 = $con->query($query5);
if($result4){
echo"$sponsorkid2";
echo"Successfully updated";
header("Location: ThanksS.php");
}
else{
echo"some error in updating";
}
if($result5){
echo"Successfully sponsored";
}
else{
echo"Some problem";
}
}
?>
</form>
</div>
</div>
</body>
</html>