| Current Path : /var/www/html/mmishra/istore/user/ |
| Current File : /var/www/html/mmishra/istore/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;
?>
Enter your query to locate student record. You may use partial information in your query.
<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 "
<select name='qField'>$str</select>
<input type='text' name='qValue' value='$qValue' size='20'>
<input type='submit' name='submit' value='QUERY'>
";
}
?>
</div>
<center>
<br>
<?php
if ($qField && $qValue) {
if ($user) {
$rs = mysql_query("select accessto from webusers where userid='$user'");
$o = mysql_fetch_object($rs);
if ($o) {
$accessto = $o->accessto;
} else {
$accessto = "course_name,year,name_eng,r_number,dob,category,Gender,area,communication_address_1";
}
}
if ($more == '1') $accessto = '*';
$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><div align='right'>[ <a href='?rno=$rno&more=$more'>";
if ($more) echo 'More';
else echo 'Less';
echo "...</a> ]</div>
<img src='http://172.31.1.40/Photo/${rno}.jpg' width='100' height='100' border='1' />
<br>Photograph";
} else {
echo "Sorry! record against above query does not exist.";
}
}
?>
</center>
<?php
echo $footer;
?>