Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/sip/user/
Upload File :
Current File : /var/www/html/mmishra/sip/user/index.php

<?php
require("../init.inc.php");

//exit on session expiry
if (!$user) header("Location: /");

if ($role == 'guest') {
	header("Location: /guest/");
}

$tbl = 'students';
$qField = $_REQUEST["qField"];
$qValue = $_REQUEST["qValue"];
$more = $_REQUEST["more"];

echo $header;

?>
Please frame your query using partial information.
<div align='center'>

<?php
$rs = mysql_query("select course_name,year,name_eng,r_number,communication_address_1,communication_address_city,communication_address_state from $tbl limit 0,1");
if (mysql_num_rows($rs)) {
        $colHeads = mysql_num_fields($rs);

        for ($i=0; $i < $colHeads; $i++) { // Header
		$fld = mysql_field_name($rs, $i);
		$lvl = ucwords(str_replace("_"," ",mysql_field_name($rs, $i)));
        	$str .= "<option value='$fld'";
		if ($qField == $fld) $str .= ' selected';
		$str .= ">$lvl</option>";
	}
}




if ($user) {
	echo "
	String <input type='text' name='qValue' value='$qValue' size='20'>
	in <select name='qField'>$str</select>
	<input type='submit' name='submit' value='QUERY'>
	";
}
?>

</div>
<center>
<br>
<?php
if ($qField && $qValue) {
	if ($more == '1') 
		$accessto = '*';
	else
		$accessto = "course_name,year,name_eng,r_number,dob,category,Gender,area,communication_address_1";

	$rs = mysql_query("select $accessto from $tbl where $qField like '%$qValue%'");
	if (mysql_num_rows($rs)) {
		$colHeads = mysql_num_fields($rs);
		
		echo "<table width='90%' border='1'>\n";

		if ($accessto == '*') {
			$q = mysql_fetch_array($rs);
                	for ($i=0; $i < $colHeads; $i++) { // Header
                        	$lvl = ucwords(str_replace("_"," ",mysql_field_name($rs, $i)));
                        	$vlu = $q[$i];
                        	echo "<tr><th>$lvl</th><td>$vlu</td></tr>\n";
                	}

			$more = FALSE;

		} else {
			echo "<tr><th>No.</th>";
			for ($i=0; $i < $colHeads; $i++) { // Header
				$fld = ucwords(str_replace("_"," ",mysql_field_name($rs, $i)));
				echo "<th>$fld</th>"; 
			}

			echo "</tr>\n";

			while ($row = mysql_fetch_row($rs)) { //data
				$no++; 
				echo "<tr><td>$no</td><td>".implode($row,'</td><td>')."</td></tr>\n"; 
			}

			if ($role == 'admin') $more = TRUE;
		}
                echo "</table>";
	} else {
		echo "Sorry! record against above query does not exist.";
	}
}
?>

</center>

<?php

echo $footer;

?>