Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function badinput($msg)
- {
- echo <<< BADINPUT
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head><?php
- function badinput($msg)
- {
- echo <<< BADINPUT
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Bad Input</title>
- </head>
- <body>
- <h1>Error</h1>
- <p>Input could not be used because $msg.</p>
- </body>
- </html>
- BADINPUT;
- }
- function connectToDatabase()
- {
- global $mysqli;
- $mysqli = new mysqli('localhost', 'root', '12341234', '110ass3');
- if(mysqli_connect_errno()){
- $problem = mysqli_connect_errno();
- badinput($problem);
- exit;
- }
- }
- function display_form()
- {
- $subjectname=array();
- $n=0;
- $m=0;
- connectToDatabase();
- echo"<html><head><script src='formcheck.js'></script>
- <script type='text/javascript'>
- var jq=jQuery.noConflict();
- jq(document).ready(function(){
- jq('#thtitle1').click(function(){
- jq('#mytable').tablesorter({sortList:[[0,0]]});
- });
- jq('#thtitle2').click(function(){
- jq('#mytable').tablesorter({sortList:[[1,0]]});
- });
- jq('#thtitle3').click(function(){
- jq('#mytable').tablesorter({sortList:[[2,0]]});
- });
- jq('#thtitle4').click(function(){
- jq('#mytable').tablesorter({sortList:[[3,0]]});
- });
- });
- </script>
- </head><body><center><h1>Faculty subject offerings</h1>
- </center><h1>Faculty</h1><form><select id='users' name='users' onchange='showuser(this.value)'>";
- $mysqli=new mysqli('localhost','root','12341234','Exercise5');
- $stmt=$mysqli->query("select * from ErehwonSubjects");
- while($row=$stmt->fetch_array())
- {
- $subjectname[$n]=$row['Subject'];
- $n++;
- }
- echo "<option>Select Subject </option>";
- for($k=0;$k<$n;$k++)
- {
- if($k+1>=$n)
- {
- break;
- }
- if($subjectname[$k]!=$subjectname[$k+1])
- {
- echo"<option value='$subjectname[$k]'>";
- echo $subjectname[$k];
- echo "</option>";
- $m++;
- }
- }
- $w=$n-1;
- echo"<option value='$subjectname[$w]'>";
- echo $subjectname[($n-1)];
- echo"</option></select></form><form><div id='txtHint'></div></form>";
- echo "</body></html>";
- }
- display_form();
- ?>
- <title>Bad Input</title>
- </head>
- <body>
- <h1>Error</h1>
- <p>Input could not be used because $msg.</p>
- </body>
- </html>
- BADINPUT;
- }
- function connectToDatabase()
- {
- global $mysqli;
- $mysqli = new mysqli('localhost', 'root', '12341234', '110ass3');
- if(mysqli_connect_errno()){
- $problem = mysqli_connect_errno();
- badinput($problem);
- exit;
- }
- }
- function display_form()
- {
- $subjectname=array();
- $n=0;
- $m=0;
- connectToDatabase();
- echo"<html><head><script src='formcheck.js'></script>
- <script type='text/javascript'>
- var jq=jQuery.noConflict();
- jq(document).ready(function(){
- jq('#thtitle1').click(function(){
- jq('#mytable').tablesorter({sortList:[[0,0]]});
- });
- jq('#thtitle2').click(function(){
- jq('#mytable').tablesorter({sortList:[[1,0]]});
- });
- jq('#thtitle3').click(function(){
- jq('#mytable').tablesorter({sortList:[[2,0]]});
- });
- jq('#thtitle4').click(function(){
- jq('#mytable').tablesorter({sortList:[[3,0]]});
- });
- });
- </script>
- </head><body><center><h1>Faculty subject offerings</h1>
- </center><h1>Faculty</h1><form><select id='users' name='users' onchange='showuser(this.value)'>";
- $mysqli=new mysqli('localhost','root','12341234','Exercise5');
- $stmt=$mysqli->query("select * from ErehwonSubjects");
- while($row=$stmt->fetch_array())
- {
- $subjectname[$n]=$row['Subject'];
- $n++;
- }
- echo "<option>Select Subject </option>";
- for($k=0;$k<$n;$k++)
- {
- if($k+1>=$n)
- {
- break;
- }
- if($subjectname[$k]!=$subjectname[$k+1])
- {
- echo"<option value='$subjectname[$k]'>";
- echo $subjectname[$k];
- echo "</option>";
- $m++;
- }
- }
- $w=$n-1;
- echo"<option value='$subjectname[$w]'>";
- echo $subjectname[($n-1)];
- echo"</option></select></form><form><div id='txtHint'></div></form>";
- echo "</body></html>";
- }
- display_form();
- ?>
Add Comment
Please, Sign In to add comment