if ( ! empty($search) ) {
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_value LIKE '%$search%' ORDER BY `$orderby` $order LIMIT $start,10", OBJECT );
}else{
$results = $cfdb->get_results( "SELECT * FROM $table_name WHERE form_post_id = $form_post_id ORDER BY `$orderby` $order LIMIT $start,10", OBJECT );
}`
When sorting by date it doesn't sort across pages but only the current page.
Example (probably shouldn't be used):
`$orderby = (isset($_GET['orderby'])) ? strreplace('-', '', $_GET['orderby']) : 'form_date'; $order = (isset($_GET['order'])) ? strreplace('-', '', $_GET['order']) : 'asc';