NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<!DOCTYPE html>

<html>

<body>

<style>

table, td, th

{

border: 1px solid black;

width: 33%;

text-align: center;

border-collapse:collapse;

background-color:lightblue;

}

table { margin: auto; }

</style>

<?php

$servername = "localhost";

$username = "root";

$password = "root";

$dbname = "weblab";

$a=[];

// Create connection

// Opens a new connection to the MySQL server

$conn = mysqli_connect($servername, $username, $password, $dbname);




Dept. of CSE, DSATM Page 27

Web Technology Lab With Mini Project – 15CSL77 2018-2019


// Check connection and return an error description from the last connection error, if any

if ($conn->connect_error)

die("Connection failed: " . $conn->connect_error);


$sql = "SELECT * FROM student";

// performs a query against the database
$result = $conn->query($sql);

echo "<br>";

echo "<center> BEFORE SORTING </center>"; echo "<table border='2'>";

echo "<tr>";t

echo "<th>USN</th><th>NAME</th><th>Address</th></tr>"; if ($result->num_rows> 0)

{

// output data of each row and fetches a result row as an associative array

while($row = $result->fetch_assoc()){

echo "<tr>";

echo "<td>". $row["usn"]."</td>";

echo "<td>". $row["name"]."</td>";

echo "<td>". $row["addr"]."</td></tr>";

array_push($a,$row["usn"]);

}

}

else

echo "Table is Empty";

echo "</table>";

$n=count($a);

$b=$a;

for ( $i = 0 ; $i< ($n - 1) ; $i++ )

{

$pos= $i;


Dept. of CSE, DSATM Page 28

Web Technology Lab With Mini Project – 15CSL77 2018-2019


for ( $j = $i + 1 ; $j < $n ; $j++ ) {

if ( $a[$pos] > $a[$j] )

$pos= $j;

}

if ( $pos!= $i ) {

$temp=$a[$i];

$a[$i] = $a[$pos];

$a[$pos] = $temp;

}

}

$c=[];

$d=[];

$result = $conn->query($sql);

if ($result->num_rows> 0)// output data of each row

{

while($row = $result->fetch_assoc()) {

for($i=0;$i<$n;$i++) {

if($row["usn"]== $a[$i]) {

$c[$i]=$row["name"];

$d[$i]=$row["addr"];

}

}

}

}

echo "<br>";

echo "<center> AFTER SORTING <center>";

echo "<table border='2'>";

echo "<tr>";

echo "<th>USN</th><th>NAME</th><th>Address</th></tr>"; for($i=0;$i<$n;$i++) {

echo "<tr>";

echo "<td>". $a[$i]."</td>";

echo "<td>". $c[$i]."</td>";


Dept. of CSE, DSATM Page 29

Web Technology Lab With Mini Project – 15CSL77 2018-2019


echo "<td>". $d[$i]."</td></tr>";

}

echo "</table>";

$conn->close();

?>

</body>

</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.