-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10a.php
More file actions
76 lines (67 loc) · 1.26 KB
/
10a.php
File metadata and controls
76 lines (67 loc) · 1.26 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
<?php
$connect = mysqli_connect("localhost","root","root","student");
$id=array();
$i=0;
$s="select * from stud";
$res=mysqli_query($connect, $s);
if(mysqli_num_rows($res)>0)
{
echo "<h3>Before Sorting</h3>";
while($row=mysqli_fetch_assoc($res))
{
$id[$i]=$row['usn'];
echo $id[$i]."<br/>";
$i++;
}
$id=sorting($id);
}
echo "<h3>After Sorting</h3>";
for($k=0;$k<count($id);$k++)
{
echo $id[$k]."<br/>";
}
echo "<h3>Sorted Data</h3>";
echo "<table border='2'><th>USN</th><th>NAME</th><th>EMAIL</th><th>MOBILE</th>";
for($k=0;$k<count($id);$k++)
{
$sq="select * from stud where usn='$id[$k]'";
$result=mysqli_query($connect,$sq);
if(mysqli_num_rows($result)>0)
{
if($row=mysqli_fetch_assoc($result))
{
echo "<tr>";
echo "<td>".$row['usn']."</td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['email']."</td>";
echo "<td>".$row['mob']."</td>";
echo "</tr>";
}
}
}
echo "</table>";
function sorting($list)
{
$len=count($list);
$x=0;
$y=0;
for($y=0;$y<$len-1;$y++)
{
$min=$y;
for($x=$y+1; $x< $len;$x++)
{
if($list[$x]<$list[$min])
{
$min=$x;
}
}
if($min!=$y)
{
$temp=$list[$y];
$list[$y]=$list[$min];
$list[$min]=$temp;
}
}
return $list;
}
?>