0

Hi

can any one please help me with some sample for multiple textbox value in php search.

all the fields in the search are in one table.

I have attached screen for the reference.

a4ec5f0f3cab021bb2e13c6b18d4c008

3
Contributors
6
Replies
33
Views
3 Years
Discussion Span
Last Post by Kon Hu
0

its SQL with ODBC

if(($_REQUEST['suser']<>'') || ($_REQUEST['jobno']<>'') || ($_REQUEST['jstatus']<>'') || ($_REQUEST['jsdate']<>''))
{
    $sql = "SELECT * from tablename where JCUSER LIKE '%".$_REQUEST['suser']."%' OR JCJOBNBR LIKE '%".$_REQUEST['jobno']."%' OR JCJOBSTS LIKE '%".$_REQUEST['jstatus']."%' OR JCSBMDATE LIKE '%".$_REQUEST['jsdate']<>."%' order by JCPROCESSID desc";
    $objExec = odbc_exec($connection,$sql);
    $Num_Rows = 0;
    while(odbc_fetch_row($objExec)) $Num_rows++;
    $Per_Page = 60;
    $Page = $_GET["Page"];
    if(!$_GET["Page"])
    {
      $Page=1;
    }
    $Prev_Page = $Page-1;
    $Next_Page = $Page+1;

    $Page_Start =(($Per_Page*$Page)-$Per_Page)+1;
    if($Num_Pages<=$Per_Page)
    {
      $Num_Pages = 1;
    }
    else if(($Num_Rows % $Per_Page)==0)  
            {  
                $Num_Pages =($Num_Rows/$Per_Page) ;  
            }  
    else  
    {  
        $Num_Pages =($Num_Rows/$Per_Page)+1;  
        $Num_Pages = (int)$Num_Pages;  
    }  
    $Page_End = $Per_Page * $Page;  
    if($Page_End > $Num_Rows)  
    {  
        $Page_End = $Num_Rows;  
    } 

    for($i=$Page_Start;$i<=$Page_End;$i++)  
    {  
        $objResult = odbc_fetch_array($objExec,$i);  

      echo "Print Area";
     }

     if($Prev_Page)  
                                        {  
                                        echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>&laquo;</a> ";  
                                        }  

                                        for($i=1; $i<=$Num_Pages; $i++)
                                        {  
                                        if($i != $Page)  
                                        {  
                                        echo " [ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ] "; 
                                        }  
                                        else  
                                        {  
                                        echo " <b> $i </b> ";  
                                        }  
                                        }  
                                        if($Page!=$Num_Pages)  
                                        {  
                                        echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>&raquo;</a> ";  
                                        } 

}

Edited by rpv_sen: add more option

2

I don't use odbc, but pdo has a wrapper for it I believe. So...

<?php

/* tests
    $_GET = array("suser"=>"an user"); // just suser
    $_GET = array("suser"=>"an user","jsdate"=>"some date"); //suser and jsdate
    $_GET = array("super"=>"a super user"); //no common keys
    $_GET = array("super"=>"a super user", jsdate=>"some date"); //just jsdate
*/

$whereString = '';
$bind = NULL;

if($_GET)
{
    $searchFields = array('suser'=>'JCUSER','jobno'=>'JCJOBNBR','jstatus'=>'JCJOBSTS','jsdate'=>'JCSBMDATE');
    if($get = array_filter($_GET))
    {
        if($fields = array_intersect_key($searchFields, $get))
        {
            $where = array();
            $bind = array();
            foreach($fields as $key=>$field)
            {
                $where[] = "`$field` LIKE '%' || :$key || '%'";
                $bind[":$key"] = $get[$key];        
            }
            $whereString = ' WHERE ' . implode(' OR ', $where);
        }
    }
}

$stmt = $pdo->prepare('SELECT * from tablename' . $whereString . ' ORDER BY JCPROCESSID DESC');
$stmt->execute($bind);


?>

Edited by diafol

Votes + Comments
Nice
1

Sorry for delay post

Hi diafol

Its working fine

Thanks

Votes + Comments
Good man! :)
-1

Heyy RPV_sen plz provide me that script I need your script for my college project plz bro plz submit a .zip link here

Votes + Comments
Necroposting nonsense
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.