Viewing file: student_search_branch.php (5.13 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Student Search </title> </head> <center> <body> <table width="946" border="0" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC"> <tr> <td colspan="4" bgcolor="#FFFF00"><?php include('header.php'); ?></td> </tr> <tr> <td colspan="4" bgcolor="#FFFF00"><?php include('menubar.php'); ?></td> </tr> </table> <form action="" method="get" name="form"> <table width="1031" border="1" cellspacing="1" cellpadding="1"> <tr align="left" width="100"> <td width="79" bgcolor="#FFCC00"><select name="y"> <option>2014</option> <option>2015</option> <option>2016</option> <option>2017</option> </select></td> <td width="139" bgcolor="#FFCC00"> <?php // Create connection $con=mysqli_connect("localhost","mitm_user","mitmpass838","mitm_ailwssor_database");
// Check connection if (mysqli_connect_errno())
// Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else { echo "We are connected."; }
$result = mysqli_query($con,"SELECT ID, username FROM branchlogin ");
?> <select name="q" id="q" > <? while($row = mysqli_fetch_array($result)) { echo "<option value='" . $row['username'] . "'>" . $row['username'] . "</option>"; } ?> </select></td> <td width="255" bgcolor="#FFCC00"> </td> <td width="415" bgcolor="#FFCC00"><input type="submit" name="Submit" value="Search" /></td> </tr> </table> </form>
<form id="form1" name="form1" method="post" action="registration_edit.php">
<?php
// Get the search variable from URL
$var = @$_GET['q'] ; $vary = @$_GET['y'] ; $trimmed = trim($var); //trim whitespace from the stored variable $trimmedy = trim($vary); // rows to return $limit=1000;
// check for an empty string and display a message. if ($trimmed == "") { exit; }
// check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; }
mysql_connect("localhost","mitm_user","mitmpass838"); //(host, username, password)
//specify database ** EDIT REQUIRED HERE ** mysql_select_db("mitm_ailwssor_database") or die("Unable to select database"); //select which database we're using
// Build SQL Query $query = "select * from student_admission where branch like \"$trimmed\" AND cyear like \"$trimmedy\" order by ID"; // EDIT HERE and specify your table and field names for the SQL query
$numresults=mysql_query($query); $numrows=mysql_num_rows($numresults);
// If we have no results, offer a google search as an alternative
if ($numrows == 0) { echo " Sorry, $trimmed this Number is not found";
}
// next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; }
// get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); echo "<table width=\"1030\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#33CCCC\" style='table-layout:fixed'>\n"; echo " <tr>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>LASER NO</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>STUDENT NAME</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>MOBILE NO</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>COURSE NAME</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>ADMISSION DATE</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>COURSE FEE</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>BRANCH</td>\n";
echo "</table>";
// begin to show results set $count = 1 + $s ;
// now you can display the results returned while ($row= mysql_fetch_array($result)) {
echo "<table width=\"1030\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFCC33\" style='table-layout:fixed'>\n"; echo " <tr>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[roll_no]</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[stduentname]</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[mobileno]</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[subject1]</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[tdate]</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[totalfees]</td>\n"; echo " <td width=\"100\" colspan=\"4\" align='left'>$row[branch]</td>\n";
echo "</table>";
$count++ ; }
$currPage = (($s/$limit) + 1);
//break before paging echo "";
// next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print "<a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a> "; }
// calculate number of pages needing links $pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
?> </form>
</body></center> </html>
|