| Current Path : /var/www/html/mmishra/iws8/html/mcell/backup/ |
| Current File : /var/www/html/mmishra/iws8/html/mcell/backup/status_search.php |
<?php
//show page head
include "page_header.inc";
$db = $_REQUEST["db"];
$submit = $_POST["submit"];
$start_pos = $_REQUEST["start_pos"];
$sfield = $_REQUEST["sfield"];
$svalue = $_REQUEST["svalue"];
$smatch = $_REQUEST["smatch"];
$page_size = $_REQUEST["page_size"];
echo "<input type='hidden' name='db' value='$db'>";
if ($start_pos == "") $start_pos = 0;
if ($page_size == "") $page_size = 20;
switch ($submit){
case "NEXT":
$start_pos = $start_pos + $page_size;
break;
case "PREVIOUS":
$start_pos = $start_pos - $page_size;
break;
default:
$start_pos = 0;
break;
}
//echo "from $start_pos to ($start_pos + $page_size)";
switch ($db){
case "available_item":
$sql1 = "select * from category_master where stock_quantity > 0";
$ttl = "Available Item";
break;
case "issued_item":
$sql1 = "select * from consumption_master";
$ttl = "Issued Item";
break;
case "scrap_item":
$sql1 = "select * from stock_master where status='scrap'";
$ttl = "Scrap Item";
break;
case "user_account":
$sql1 = "select * from consumption_master";
$ttl = "User";
break;
case "job_list":
$sql1 = "select * from job_master";
$ttl = "Job";
break;
case "category_list":
$sql1 = "select Category_code, Description, Stock_quantity, Issued_quantity, S
crap_quantity from category_master";
$ttl = "Category";
break;
default:
$sql1 = "select * from item_master";
$ttl = "Item";
break;
}
$sql2 = $sql1;
//$sql2 = "select found_rows(); mysql_calc_found_rows
$result2 = mysql_query($sql2, $link_id);
$query_data2 = mysql_fetch_row($result2);
echo "<div align='right'><b>$ttl</b> search in ";
echo "<select name='sfield'><option value=''>Select column</option>";
foreach($query_data2 as $a => $c){
echo "<option value='" . ucfirst(mysql_field_name($result2, $a)) . "'";
if (ucfirst(mysql_field_name($result2, $a)) == $sfield) echo " selected";
echo ">" . ucfirst(mysql_field_name($result2, $a)) . "</option>";
}
echo "</select> value <input type='text' name='svalue' size='10' value='$svalue'> as ";
echo "<select name='smatch'><option value='1'>Any where</option><option value='2'";
if ($smatch == "2") echo " selected";
echo ">Initial</option><option value='3'";
if ($smatch == "3") echo " selected";
echo ">Exact</option></select> ";
echo "<input type='submit' name='submit' value='SEARCH'></div><br>";
if ($sfield > ""){
if (!strpos($sql1, "where"))
$sql1 .= " where";
else
$sql1 .= " and";
switch ($smatch){
case "2":
$sql1 .= " $sfield like '$svalue%'";
break;
case "3":
$sql1 .= " $sfield = '$svalue'";
break;
default://case "1":
$sql1 .= " $sfield like '%$svalue%'";
break;
}
$sql2 = $sql1;
$sql1 .= " order by $sfield";
}
$sql1 .= " limit $start_pos, $page_size";
$result1 = mysql_query($sql1, $link_id);
$result2 = mysql_query($sql2, $link_id);
if(!$result1) echo sql_error();
$query_data1 = mysql_fetch_row($result1);
$query_data2 = mysql_fetch_row($result2);
echo "<b>Search Result:</b> (";
$total_records = mysql_num_rows($result2);
if (!$total_records)
echo "No $ttl found)<p>";
else{
echo $total_records . " $ttl found)";
//show table data
echo table_data($sql1, $link_id, $start_pos, $db);
echo "<div align='right'>Click on column heading to sort result on that column values. ";
echo "Display <input type='text' name='page_size' value='$page_size' size='2'> records per page ";
echo "<input type='hidden' name='start_pos' value='$start_pos'>";
if ($start_pos >= $page_size){
echo "<input type='submit' name='submit' value='PREVIOUS'> ";
}
$start_pos = $start_pos + $page_size;
if ($start_pos < $total_records) echo "<input type='submit' name='submit' value='NEXT'>";
echo "</div>";
}
include "page_footer.inc";
?>