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

Member Avatar for diafol

Show us your efforts so far.

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> ";  
                                        } 

}
Member Avatar for diafol

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);


?>
commented: Nice +12

thanks.

I will get back once i test

Sorry for delay post

Hi diafol

Its working fine

Thanks

commented: Good man! :) +15

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

commented: Necroposting nonsense -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.