server side search

server side search

mmontoyammontoya Posts: 84Questions: 27Answers: 4

how do I reference the search[value] post?

I tried: $_POST['search[value]']

but this didn't work.

This question has accepted answers - jump to:

Answers

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4
    edited February 2016 Answer ✓

    got it...

        $search = $_POST['search'];
        if (!empty($search['value'])) {
            $sql .= " Having searchField like '%".$search['value']."%'"; 
        }
    
        $orderBy = $_POST['order'];
        $orderCol =  intval($orderBy[0]['column']);
            $sql .= " order by " . $orderCol . " " . $orderBy[0]['dir']; 
    

    where searchField is a concat of all the fields displayed in the table.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓
    $_POST['search']['value']
    

    is how you would do it if you wanted to access it directly from $_POST.

    Allan

  • mmontoyammontoya Posts: 84Questions: 27Answers: 4

    Ahh. That is a lot cleaner than mine :)

    Thanks

This discussion has been closed.