| Current Path : /var/www/html/mmishra/istore/ |
| Current File : /var/www/html/mmishra/istore/storesearch.inc |
<h3>Search in Store</h3>
<center>
<?php
$str = $_REQUEST["str"];
echo "Search text <input type='text' name='str' value='$str' size='30' onchange=\"javascript: document.location.href='?pg=$pg&str='+this.value\">
<input type='submit' name='submit' value='SEARCH'>";
if ($str) {
//employee search
echo "<div align='left'><b>Employee</b></div>";
echo query("select emp_no,emp_name,designation,email,contact from employees where concat(emp_name,designation,email) like '%$str%'");
//material search
echo "<div align='left'><b>Store Items</b></div>";
echo query("select c.code as category,s.code as item,i.code as specification,i.description from st_items as i,st_category as c,st_subcategory as s where i.category=c.id and i.subcategory=s.id and concat(c.code,s.code,i.code,i.description) like '%$str%'");
//indentor
echo "<div align='left'><b>Indentor</b></div>";
echo query("select i.emp_no,e.emp_name,i.indent_no,i.location,i.purpose,i.recommendation from indents as i left join employees as e on i.emp_no=e.emp_no where concat(e.emp_name,e.designation,i.location,i.purpose,i.recommendation) like '%$str%'");
//indent item
echo "<div align='left'><b>Indent Items</b></div>";
echo query("select i.indent_no,c.code as category,s.code as item,t.code as specification,t.description from indents as i,indent_items as ii,st_items as t,st_category as c,st_subcategory as s where i.indent_no=ii.indent_no and ii.item=t.id and t.category=c.id and t.subcategory=s.id and concat(c.code,s.code,t.code,t.description) like '%$str%'");
}
function query($sql) {
$rs = mysql_query($sql);
if (mysql_num_rows($rs)) {
$colHeads = mysql_num_fields($rs);
$mm = "<table border='1' width='90%'><tr><th>Sr</th>";
for ($i=0; $i < $colHeads; $i++) {
$mm .= "<th>". ucwords(str_replace("_"," ",mysql_field_name($rs, $i))) ."</th>";
}
$mm .= "</tr>";
$j = 0;
while ($row = mysql_fetch_row($rs)) {
$j++;
$mm .= "<tr><td>$j</td><td>".implode($row,"</td><td>")."</td></tr>\n";
}
$mm .= "</table>";
} else {
$mm = "<h3>None</h3>";
}
return $mm;
}
?>
</center>