function show_spider_event($calendar_id) { global $wpdb; $order = " ORDER BY title ASC"; $sort["default_style"] = "manage-column column-autor sortable desc"; $sort["sortid_by"] = "title"; $sort["custom_style"] = "manage-column column-title sorted asc"; $sort["1_or_2"] = "2"; if (isset($_POST['page_number'])) { if (isset($_POST['order_by']) && esc_html($_POST['order_by']) != '') { $sort["sortid_by"] = esc_sql(esc_html(stripslashes($_POST['order_by']))); } if (isset($_POST['asc_or_desc']) && esc_html($_POST['asc_or_desc']) == 1) { $sort["custom_style"] = "manage-column column-title sorted asc"; $sort["1_or_2"] = "2"; $order = "ORDER BY " . $sort["sortid_by"] . " ASC"; } else { $sort["custom_style"] = "manage-column column-title sorted desc"; $sort["1_or_2"] = "1"; $order = "ORDER BY " . $sort["sortid_by"] . " DESC"; } if (isset($_POST['page_number']) && esc_html($_POST['page_number'])) { $limit = (esc_sql(esc_html(stripslashes($_POST['page_number']))) - 1) * 20; } else { $limit = 0; } } else { $limit = 0; } if (isset($_POST['search_events_by_title'])) { $search_tag = esc_sql(esc_html(stripslashes($_POST['search_events_by_title']))); } else { $search_tag = ""; } if ($search_tag) { $where = ' AND ' . $wpdb->prefix . 'spidercalendar_event.title LIKE "%%' . like_escape($search_tag) . '%%"'; } else { $where = ''; } if (isset($_POST['startdate']) && esc_html($_POST['startdate'])) { $where .= ' AND ' . $wpdb->prefix . 'spidercalendar_event.date > \'' . esc_sql(esc_html(stripslashes($_POST['startdate']))) . '\' '; } if (isset($_POST['enddate']) && $_POST['enddate']) { $where .= ' AND ' . $wpdb->prefix . 'spidercalendar_event.date < \'' . esc_sql(esc_html(stripslashes($_POST['enddate']))) . '\' '; } // Get the total number of records. $query = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "spidercalendar_event WHERE calendar=%d " . $where . " ", $calendar_id); $total = $wpdb->get_var($query); $pageNav['total'] = $total; $pageNav['limit'] = $limit / 20 + 1; $query = $wpdb->prepare("SELECT " . $wpdb->prefix . "spidercalendar_event.*, " . $wpdb->prefix . "spidercalendar_event_category.title as cattitle FROM " . $wpdb->prefix . "spidercalendar_event LEFT JOIN " . $wpdb->prefix . "spidercalendar_event_category ON " . $wpdb->prefix . "spidercalendar_event.category=" . $wpdb->prefix . "spidercalendar_event_category.id\n\tWHERE calendar=%d " . $where . " " . $order . " " . " LIMIT %d,20", $calendar_id, $limit); $rows = $wpdb->get_results($query); $cal_name = $wpdb->get_var($wpdb->prepare('SELECT title' . ' FROM ' . $wpdb->prefix . 'spidercalendar_calendar WHERE `id`="%d"', $calendar_id)); html_show_spider_event($rows, $pageNav, $sort, $calendar_id, $cal_name); }
function show_spider_event($calendar_id) { global $wpdb; $sort["default_style"] = "manage-column column-autor sortable desc"; if (isset($_POST['page_number'])) { if ($_POST['asc_or_desc']) { $sort["sortid_by"] = $wpdb->escape($_POST['order_by']); if ($_POST['asc_or_desc'] == 1) { $sort["custom_style"] = "manage-column column-title sorted asc"; $sort["1_or_2"] = "2"; $order = "ORDER BY " . $sort["sortid_by"] . " ASC"; } else { $sort["custom_style"] = "manage-column column-title sorted desc"; $sort["1_or_2"] = "1"; $order = "ORDER BY " . $sort["sortid_by"] . " DESC"; } } if ($_POST['page_number']) { $limit = ($_POST['page_number'] - 1) * 20; } else { $limit = 0; } } else { $limit = 0; } if (isset($_POST['search_events_by_title'])) { $search_tag = $_POST['search_events_by_title']; } else { $search_tag = ""; } if ($search_tag) { $where = ' AND title LIKE "%' . $search_tag . '%"'; } if (isset($_POST['startdate'])) { if ($_POST['startdate']) { $where .= ' AND date > \'' . $_POST['startdate'] . '\' '; } } if (isset($_POST['enddate'])) { if ($_POST['enddate']) { $where .= ' AND date < \'' . $_POST['enddate'] . '\' '; } } // get the total number of records $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "spidercalendar_event WHERE calendar=" . $calendar_id . " " . $where . " "; $total = $wpdb->get_var($query); $pageNav['total'] = $total; $pageNav['limit'] = $limit / 20 + 1; $query = "SELECT * FROM " . $wpdb->prefix . "spidercalendar_event WHERE calendar=" . $calendar_id . " " . $where . " " . $order . " " . " LIMIT " . $limit . ",20"; $rows = $wpdb->get_results($query); $cal_name = $wpdb->get_var('SELECT title' . ' FROM ' . $wpdb->prefix . 'spidercalendar_calendar WHERE id=' . $calendar_id); // display function html_show_spider_event($rows, $pageNav, $sort, $calendar_id, $cal_name); }