How do I return NO RECORDs or another webpage until there is a search entered?

How do I return NO RECORDs or another webpage until there is a search entered?

GstgGstg Posts: 65Questions: 4Answers: 0

Our DataTables are working great, thanks to the community and Allan in particular.

We will have millions of records in our searches, and we'd like to return either NO RECORDS or another webpage until a search is entered, so that we only return searched records instead of all records. The easiest way to think about this is a Google search. If you search in Google, it returns results, but if you blank out the search, it doesn't return all results for all searches. In our case unless they search we don't want to process all the records in the tables.

Thanks in advance for your thoughts on this.

Replies

  • allanallan Posts: 61,437Questions: 1Answers: 10,049 Site admin

    Hi,

    I've just sent a reply by e-mail, but in summary what to do is in your server-side processing script, add a check to see if any search is being performed. If there is not then you can return an empty data set - for example:

      if ( empty($_POST['search']['value']) ) {
        echo json_encode([
          "data" => []
        ]);
        exit;
      }
    

    Regards,
    Allan

  • GstgGstg Posts: 65Questions: 4Answers: 0

    Thanks 8-)

Sign In or Register to comment.