prefix . "huge_it_contact_contacts WHERE hc_width=0"; $cat_row = $wpdb->get_results( $cat_row_query ); // get the total number of records $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "huge_it_contact_contacts" . $where; $total = $wpdb->get_var( $query ); $pageNav['total'] = $total; $pageNav['limit'] = $limit / 20 + 1; if($cat_id){ $query = "SELECT a.* , COUNT(b.id) AS count, g.par_name AS par_name FROM " . $wpdb->prefix . "huge_it_contact_contacts AS a LEFT JOIN " . $wpdb->prefix . "huge_it_contact_contacts AS b ON a.id = b.hc_width LEFT JOIN (SELECT " . $wpdb->prefix . "huge_it_contact_contacts.ordering as ordering," . $wpdb->prefix . "huge_it_contact_contacts.id AS id, COUNT( " . $wpdb->prefix . "huge_it_contact_contacts_fields.hugeit_contact_id ) AS prod_count FROM " . $wpdb->prefix . "huge_it_contact_contacts_fields, " . $wpdb->prefix . "huge_it_contact_contacts WHERE " . $wpdb->prefix . "huge_it_contact_contacts_fields.hugeit_contact_id = " . $wpdb->prefix . "huge_it_contact_contacts.id GROUP BY " . $wpdb->prefix . "huge_it_contact_contacts_fields.hugeit_contact_id) AS c ON c.id = a.id LEFT JOIN (SELECT " . $wpdb->prefix . "huge_it_contact_contacts.name AS par_name," . $wpdb->prefix . "huge_it_contact_contacts.id FROM " . $wpdb->prefix . "huge_it_contact_contacts) AS g ON a.hc_width=g.id WHERE a.name LIKE '%" . $search_tag . "%' group by a.id " . $order . " LIMIT " . $limit . ",20"; } else{ $query ="SELECT a.* , COUNT(b.id) AS count, g.par_name AS par_name FROM ".$wpdb->prefix."huge_it_contact_contacts AS a LEFT JOIN ".$wpdb->prefix."huge_it_contact_contacts AS b ON a.id = b.hc_width LEFT JOIN (SELECT ".$wpdb->prefix."huge_it_contact_contacts.ordering as ordering,".$wpdb->prefix."huge_it_contact_contacts.id AS id, COUNT( ".$wpdb->prefix."huge_it_contact_contacts_fields.hugeit_contact_id ) AS prod_count FROM ".$wpdb->prefix."huge_it_contact_contacts_fields, ".$wpdb->prefix."huge_it_contact_contacts WHERE ".$wpdb->prefix."huge_it_contact_contacts_fields.hugeit_contact_id = ".$wpdb->prefix."huge_it_contact_contacts.id GROUP BY ".$wpdb->prefix."huge_it_contact_contacts_fields.hugeit_contact_id) AS c ON c.id = a.id LEFT JOIN (SELECT ".$wpdb->prefix."huge_it_contact_contacts.name AS par_name,".$wpdb->prefix."huge_it_contact_contacts.id FROM ".$wpdb->prefix."huge_it_contact_contacts) AS g ON a.hc_width=g.id WHERE a.name LIKE '%".$search_tag."%' group by a.id ". $order ." LIMIT ".$limit.",20"; } $rows = $wpdb->get_results( $query ); global $glob_ordering_in_cat; if ( isset( $sort["sortid_by"] ) ) { if ( $sort["sortid_by"] == 'ordering' ) { if ( $_POST['asc_or_desc'] == 1 ) { $glob_ordering_in_cat = " ORDER BY ordering ASC"; } else { $glob_ordering_in_cat = " ORDER BY ordering DESC"; } } } $rows = hugeit_contact_open_cat_in_tree( $rows ); $query = "SELECT ".$wpdb->prefix."huge_it_contact_contacts.ordering,".$wpdb->prefix."huge_it_contact_contacts.id, COUNT( ".$wpdb->prefix."huge_it_contact_submission.contact_id ) AS prod_count FROM ".$wpdb->prefix."huge_it_contact_submission, ".$wpdb->prefix."huge_it_contact_contacts WHERE ".$wpdb->prefix."huge_it_contact_submission.contact_id = ".$wpdb->prefix."huge_it_contact_contacts.id GROUP BY ".$wpdb->prefix."huge_it_contact_submission.contact_id"; $prod_rows = $wpdb->get_results($query); foreach ( $rows as $row ) { foreach ( $prod_rows as $row_1 ) { if ( $row->id == $row_1->id ) { $row->ordering = $row_1->ordering; $row->prod_count = $row_1->prod_count; } } } $query = "SELECT * FROM " . $wpdb->prefix . "huge_it_contact_styles order by id ASC"; $form_styles = $wpdb->get_results( $query ); $cat_row = hugeit_contact_open_cat_in_tree( $cat_row ); hugeit_contact_html_showhugeit_contacts( $rows, $pageNav, $sort, $cat_row, $form_styles ); } function hugeit_contact_open_cat_in_tree( $catt, $tree_problem = '', $hihiih = 1 ) { global $wpdb; global $glob_ordering_in_cat; static $trr_cat = array(); if ( ! isset( $search_tag ) ) { $search_tag = ''; } if ( $hihiih ) { $trr_cat = array(); } foreach ( $catt as $local_cat ) { $local_cat->name = $tree_problem . $local_cat->name; array_push( $trr_cat, $local_cat ); $new_cat_query = "SELECT a.* , COUNT(b.id) AS count, g.par_name AS par_name FROM " . $wpdb->prefix . "huge_it_contact_contacts AS a LEFT JOIN " . $wpdb->prefix . "huge_it_contact_contacts AS b ON a.id = b.hc_width LEFT JOIN (SELECT " . $wpdb->prefix . "huge_it_contact_contacts.ordering AS ordering," . $wpdb->prefix . "huge_it_contact_contacts.id AS id, COUNT( " . $wpdb->prefix . "huge_it_contact_submission.contact_id ) AS prod_count FROM " . $wpdb->prefix . "huge_it_contact_submission, " . $wpdb->prefix . "huge_it_contact_contacts WHERE " . $wpdb->prefix . "huge_it_contact_submission.contact_id = " . $wpdb->prefix . "huge_it_contact_contacts.id GROUP BY " . $wpdb->prefix . "huge_it_contact_submission.contact_id) AS c ON c.id = a.id LEFT JOIN (SELECT " . $wpdb->prefix . "huge_it_contact_contacts.name AS par_name," . $wpdb->prefix . "huge_it_contact_contacts.id FROM " . $wpdb->prefix . "huge_it_contact_contacts) AS g ON a.hc_width=g.id WHERE a.name LIKE '%" . $search_tag . "%' AND a.hc_width=" . $local_cat->id . " GROUP BY a.id " . $glob_ordering_in_cat; $new_cat = $wpdb->get_results( $new_cat_query ); hugeit_contact_open_cat_in_tree( $new_cat, $tree_problem . "— ", 0 ); } return $trr_cat; } function hugeit_contact_remove_submissions($id,$subId = 0){ global $wpdb; if ( $subId == 0 ) { $sql_remov_tag = $wpdb->prepare( "DELETE FROM " . $wpdb->prefix . "huge_it_contact_submission WHERE contact_id=%d", $id ); } else { $sql_remov_tag = $wpdb->prepare( "DELETE FROM " . $wpdb->prefix . "huge_it_contact_submission WHERE id=%d", $id ); } if ( ! $wpdb->query( $sql_remov_tag ) ) : ?>
Submission Not Deleted